css实现毛玻璃效果

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

 代码:


<template>
  <div class="high-quality">
  </div>
</template>


<style scoped lang="less">
.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&fm=253&fmt=auto&app=120&f=JPEG?w=300&h=300') no-repeat;
  background-size:102% ;
  background-position: center center;
  border-radius: 10px;
  filter: blur(20px); //增加毛玻璃
}
</style>

效果:

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值