码迷,mamicode.com
首页 > Web开发 > 详细

css设置背景模糊

时间:2018-10-22 16:37:58      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:样式   images   html   strong   分享图片   absolute   inf   over   com   

使用filter属性来设置模糊值

效果:

技术分享图片

 

css样式:

 

<style type="text/css">
        .cover {
            width: 600px;
            height: 300px;
            position: relative;
            text-align: center;
            line-height: 300px;
            color: #fff;
            margin: 20px auto;
        }
        
        .cover::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 600px;
            height: 300px;
            background: transparent url(Images/picture/5.jpg) center center no-repeat;
            filter: blur(8px);
            z-index: -1;
            background-size: cover;
        }
    </style>

 

HTML结构:

<body>
    <div class="cover">
        <h2>背景模糊,文字清晰显示</h2>
    </div>
</body>

  

 

css设置背景模糊

标签:样式   images   html   strong   分享图片   absolute   inf   over   com   

原文地址:https://www.cnblogs.com/qianxuebing/p/9830528.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!