+
80
-

css中如何实现背景透明而容器内文字内容不透明?

css中如何实现背景透明而容器内文字内容不透明?


网友回复

+
0
-

800_auto

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <style>
    body{
        background: url('//repo.bfw.wiki/bfwrepo/image/64fe45d51d6cb.png') no-repeat;
    }
        div {
            background: rgba(0, 0, 0, 0.2) none repeat scroll !important;/* rgba(0, 0, 0, 0.2) 前三个确定颜色,最后0.2确定透明度 */
            /*实现FireFox背景透明,文字不透明*/
            background: #ffffff;
            filter: Alpha(opacity=20);
            /*实现IE背景透明,文字不透明*/
         
            height: 300px;
            margin: 30px;
         
   
        }

        div p {
           color: white;
           padding: 10px;
                    font-size: 20px;
            font-weight: bold;
        }

        /*实现IE文字不透明*/
    </style>
</head>

<body>
    <div>
        <p>这是个background透明但是content不透明的div</p>
    </div>
</body>


</html>

我知道答案,我要回答