温馨提示×

css怎么设置背景图片透明度

css
清风
485
2021-03-11 10:20:39
栏目: 编程语言

css怎么设置背景图片透明度

css设置背景图片透明度的方法:

使用opacity属性可以设置背景图片透明度。

示例:

<!DOCTYPE html>

<html>

    <head>

        <meta charset="UTF-8">

        <title>背景图片设置</title>

        <style>

            .demo{

                position:fixed;

                top: 0;

                left: 0;

                width:100%;

                height:100%;

                min-width: 1000px;

                z-index:-10;

                zoom: 1;

                background-color: #fff;

                background: url(2.png);

                background-repeat: no-repeat;

                background-size: cover;

                -webkit-background-size: cover;

                -o-background-size: cover;

                background-position: center 0;

opacity:0.5; //设置div元素的不透明级别为0.5

            }

        </style>

    </head>

    <body>

        <div class="demo"></div>

    </body>

</html>


0