CSS实现背景图片透明而文字不透明效果的方法

1.毛玻璃效果:

背景图 + 伪类 + flite:blur(3px)

.demo1{
    width: 500px;
    height: 300px;
    line-height: 50px;
    text-align: center;
}
.demo1:before{
    background: url(http://csssecrets.io/images/tiger.jpg) no-repeat;
    background-size: cover;
    width: 500px;
    height: 300px;
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;/*-1 可以当背景*/
    -webkit-filter: blur(3px);
    filter: blur(3px);
}

<div class="demo1">背景图半透明,文字不透明 方法:背景图+ filter:blur</div>

2.rgba效果:

background: rgba(0, 0, 0, .1);

猜你喜欢

转载自blog.csdn.net/qq_37339364/article/details/83826737