div图片背景虚化不影响图片上的文字_背景图片模糊,其中文字清晰实现方法总结...

本文介绍了四种实现div背景图片虚化但不影响文字清晰的方法。包括图片叠加、背景遮罩、伪元素before以及改变元素布局关系等技术,详细展示了代码示例和效果对比。
摘要由CSDN通过智能技术生成

先上效果图:

之前:

之后:

实现方式:

第一种:两张图片叠加,上面放一个纯白色的,下面放这张清晰的医生的图

第二种:背景图片上面,使用一层遮罩,设计背景色为纯白色,并且是有一定透明度的

背景模糊文字内容不模糊

.box{

background: url("images/homebgper.png") no-repeat;

background-size: cover;

width:500px;

height: 300px;

position: relative;

}

.content{

position: absolute;

left:0;

right:0;

top:0;

bottom: 0;

width:500px;

height: 300px;

background: rgba(255,255,255,0.82)

}

第三种:使用伪元素before,在伪元素上设置尺寸和元素相同,并且背景图片设置在伪元素上,

背景模糊文字内容不模糊

.box{

width:500px;

height: 300px;

}

.box::before{

background: url("images/homebgper.png") no-repeat;

background-size: cover;

width:500px;

height: 300px;

content: "";

position: absolute;

top:0;

left:0;

z-index:-1;

opacity: 0.18;

}

第四种: 文字和背景图片所在容器不是父子关系,是兄弟关系

背景模糊文字内容不模糊

.content {

color: #000000;

font-size: 40px;

position:absolute;

}

.box{

background: url('images/homebgper.png') no-repeat;

height: 300px;

width:500px;

float: left;

background-position: center;

background-size: cover;

-webkit-filter: blur(2px);

-moz-filter: blur(2px);

-o-filter: blur(2px);

-ms-filter: blur(2px);

filter: blur(2px);

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值