国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

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

2024-07-11 09:00:23
字體:
來源:轉載
供稿:網友

前段時間在開發中,遇到需要給背景層加顏色遮罩的項目,現在特定總結一下給背景圖層加顏色遮罩的方法。

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

<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;}

方法二:通過偽類元素疊加

<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;}

總結

以上所述是小編給大家介紹的css3給背景圖片加顏色遮罩的方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!
 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 墨竹工卡县| 澄江县| 平阴县| 修水县| 绥芬河市| 饶河县| 屯门区| 金乡县| 含山县| 兖州市| 文成县| 青田县| 镇赉县| 桐城市| 安吉县| 峨山| 农安县| 海门市| 碌曲县| 远安县| 旌德县| 财经| 德钦县| 方山县| 邓州市| 陇南市| 曲麻莱县| 辽阳县| 冕宁县| 榆中县| 应城市| 嘉定区| 阿拉善盟| 高邮市| 岳西县| 油尖旺区| 芦山县| 天峻县| 腾冲县| 中宁县| 荣成市|