实现毛玻璃重点是利用filter属性blur原理是,可以一个基础盒子的伪元素设置毛玻璃滤镜,再给伪元素设置背景图,让伪元素完全覆盖这个基础盒子之上。

 代码


<template>
  <div class="high-quality">
  </div>
</template&gt;


<style scoped lang="less"&gt;
.high-quality{
 position: relative;
  width:100%;
  height: 175px;
  padding:14px;
  display: flex;
  border-radius: 10px;
  overflow: hidden; //多余的毛玻璃部分隐藏
}
.high-quality:before{
  position: absolute;
  width: 100%;
  height: 100%;
  z-index:1;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  content: '';
  display: inline-block;
  background: url('https://img2.baidu.com/it/u=2241564326,399361128&amp;fm=253&amp;fmt=auto&amp;app=120&amp;f=JPEG?w=300&amp;h=300') no-repeat;
  background-size:102% ;
  background-position: center center;
  border-radius: 10px;
  filter: blur(20px); //增加毛玻璃
}
</style>

效果

 

 

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注