使用filter属性来设置模糊值

效果:

css设置背景模糊

 

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>

  

 

相关文章:

  • 2021-05-26
  • 2021-07-11
  • 2021-12-06
  • 2022-12-23
  • 2021-12-16
  • 2021-12-06
  • 2021-12-06
  • 2022-02-06
猜你喜欢
  • 2021-08-14
  • 2021-07-16
  • 2021-06-21
  • 2022-12-23
  • 2021-12-06
  • 2021-12-06
  • 2021-11-24
相关资源
相似解决方案