css实现图⽚虚化_HTML+CSS⼊门如何实现背景图⽚虚化效
本篇教程介绍了HTML+CSS⼊门 如何实现背景图⽚虚化效果,希望阅读本篇⽂章以后⼤家有所收获,帮助⼤家HTML+CSS⼊门。
<
需求:⼀个div设置了background: url,现在需要使图⽚背景模糊,div内的⽂字清晰显⽰。
原始代码:
html>
.content {
color: #ffffff;
font-size: 40px;
}
.bg {
background: url(‘1.jpg‘);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
height:600px;
text-align: center;
line-height: 600px;
}
我是内容
原始效果:
解决⽅法:内容和图⽚分别置于⼀个div,通过css设置背景div模糊度,设置内容div绝对位置。
html代码:
html>
.content {
color: #ffffff;
font-size: 40px;
}
.bg {
background: url(‘1.jpg‘);
height:600px;
text-align: center;
line-height: 600px;
}
.bg-blur {
float: left;
width: 100%;
background-repeat: no-repeat; background-position: center; background-size: cover;
-webkit-filter: blur(15px);
css特效文字-moz-filter: blur(15px);
-o-filter: blur(15px);
-ms-filter: blur(15px);
filter: blur(15px);
}
.content-front {
position:absolute;
left: 10px;
right: 10px;
height:600px;
line-height: 600px;
text-align: center;
}
我是内容