亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

css3給背景圖片加顏色遮罩的方法

  發(fā)布時(shí)間:2019-11-05 11:48:41   作者:佚名   我要評(píng)論
前段時(shí)間在開發(fā)中,遇到需要給背景層加顏色遮罩的項(xiàng)目,現(xiàn)在特定總結(jié)一下給背景圖層加顏色遮罩的方法,感興趣的朋友跟隨小編一起看看吧

前段時(shí)間在開發(fā)中,遇到需要給背景層加顏色遮罩的項(xiàng)目,現(xiàn)在特定總結(jié)一下給背景圖層加顏色遮罩的方法。

方法一:通過(guò)定位疊加(注意層級(jí))

<div class="wrap1">
     <div class="inner"> </div>
</div>
.wrap1 {
    position: relative;
    width: 1200px;
    height: 400px;
    background: rgba(0, 0, 0, .5);
}

.wrap1 .inner {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: url(ban8.jpg) no-repeat center center;
    background-size: cover;
    z-index: -1;
}

方法二:通過(guò)偽類元素疊加

<div class="wrap2"></div>
.wrap2 {
    position: relative;
    width: 1200px;
    height: 400px;
    background: url(ban8.jpg) no-repeat center center;
    background-size: cover;
}

.wrap2::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    background-color: rgba(0, 0, 0, .5);
    z-index: 2;
}

方法三:CSS3顏色疊加background-blend-mode:multiply;(正片疊底)

<div class="wrap3"></div>
.wrap3 {
    position: relative;
    width: 1200px;
    height: 400px;
    background: url(ban8.jpg) rgba(0, 0, 0, .5) no-repeat center center;
    background-blend-mode: multiply;
}

拓展:背景模糊加顏色疊加

.wrap4 {
    position: relative;
    width: 1200px;
    height: 400px;
    background: url(ban8.jpg) rgba(0, 0, 0, .5) no-repeat center center;
    background-blend-mode: multiply;
    filter: blur(2px);
    overflow: hidden;
}

總結(jié)

以上所述是小編給大家介紹的css3給背景圖片加顏色遮罩的方法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
 

相關(guān)文章

最新評(píng)論