css模糊背景

今天写项目遇到了模糊背景,查询网上资料,学习到了filter:blur()样式。

html部分
    <!--    专辑封面-->
    <div class="albumCover">
      <div>
        <img src="../assets/picture.jpg" alt="">
        <ul>
          <li class="albumTitle">制造浪漫|动人此刻连接你我</li>
          <li>
            <div class="portrait"></div>
            <span class="anthor">买菜不用券</span>
          </li>
        </ul>
      </div>
    </div>
css部分
//专题封面
.albumCover {
  height: 220px;
  background: url("../assets/picture.jpg") no-repeat;
  background-size: cover;
  position: relative;
  z-index: -1;
  overflow: hidden;

  &:after {
    content: "";
    width: 100%;
    height: 220px;
    position: absolute;
    left: 0;
    top: 0;
    background: inherit;
    filter: blur(20px);
    z-index: 1;
  }

  img {
    z-index: 2;
    margin: 40px 20px;
    position: absolute;
    width: 140px;
  }
}

//专辑封面中的标题
.albumTitle {
  color: #fff;
  font-size: 18px;
  position: absolute;
  top: 40px;
  left: 180px;
  z-index: 2;
}

//头像
.portrait {
  width: 40px;
  height: 40px;
  background-color: #f1f1f1;
  border-radius: 50%;
  position: absolute;
  bottom: 80px;
  left: 180px;
  z-index: 2;
}

//作者
.anthor {
  color: #cdc9cb;
  position: absolute;
  bottom: 90px;
  left: 227px;
  z-index: 2;
}
页面效果

在这里插入图片描述

晚安
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值