• html之改变图片透明度而不改变文字的透明度--两种方法实现


    图片与图片上的文字设置不同的透明度的两种方法:

    第一种方法:背景图+定位+background: url(timg.jpg)no-repeat;

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .d1 {
            background: url(timg.jpg)no-repeat;
            background-size: cover;
             500px;   
            height: 500px;          
            position: relative;
        }
        .d2 {
            position: absolute;
            left: 0;
            right: 0;
            top:0;
            bottom: 0;
             500px;   
            height: 500px;
            line-height: 50px;
            text-align: center;
            background: rgba(225,225,225,0.3);          
    
        }
    </style>
    </head>
    <body>
    <div class="d1">
        <div class="d2">我是吴亦凡</div>
    </div>
    </body>
    </html>
    
    效果图一:

    第二种方法:背景图+伪类+flite:blur(5px)

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    
        .d1 {
             300px;
            height: 300px;
            line-height: 50px;
            text-align: center;
    
        }
        .d1:before {
            background: url(timg.jpg)no-repeat;
            background-size: cover;
             500px;   
            height: 500px;          
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            z-index: -1;
            -webkit-filter:blur(5px);
            filter: blur(px);
        }
    
    
    </style>
    </head>
    <body>
    <div class="d1">我是吴亦凡</div>
    </body>
    </html>
    
    效果图二:

    需要知道的几个属性:

    • background: url(timg.jpg)no-repeat;:将一张图片设置为html的背景图,并且不平铺。如果平铺的话将占满整个网页。
    • background-size: cover;:background-size的cover特定值会保持图像本身的宽高比例,将图片缩放到正好完全覆盖定义背景的区域。
    • z-index: -1;:让一个层在所有层的下面当背景的方法。
    • -webkit-filter:blur(5px);:-webkit-filter,其作用通常是进行图片处理,blur(5px)是对图像进行模糊处理,此处像素为5px。
    • filter: blur(px);用滤镜对文字进行模糊处理。
    • background: rgba(225,225,225,0.3);通过改变最后一个值来设置背景图片的透明度。
  • 相关阅读:
    HIVE的基本操作
    sqoop数据迁移
    工作流调度器azkaban
    C/s模式与B/S模式
    自动装箱和拆箱所带来的问题(1)“==”问题
    线程死锁
    模拟售票
    线程之间的通信
    线程同步引发的安全问题
    sql server 与 mysql在自定以数据类型的区别
  • 原文地址:https://www.cnblogs.com/lxmtx/p/7093954.html
Copyright © 2020-2023  润新知