栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在先前的背景图像之上添加背景图像?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在先前的背景图像之上添加背景图像?

您可以考虑CSS变量。指定2个背景层,以后可以更改。您可以轻松缩放到任意数量的背景:

.container > div {  background:        var(--im1,linear-gradient(transparent,transparent)),    var(--im2,linear-gradient(transparent,transparent));  height:200px;  width:200px;  display:inline-block;}.background1 {  --im2: url(https://picsum.photos/200/300?image=0);}.background2 {  --im2: url(https://picsum.photos/200/300?image=1069);}.backgroundFilter {  --im1: linear-gradient(to right,transparent,green);;}<div ><div >...</div><div >...</div><div >...</div><div >...</div></div>

您还可以为新背景考虑伪元素,但是由于我们只有2个伪元素,因此您只能使用3个背景:

.container > div {  height:200px;  width:200px;  display:inline-block;  position:relative;  z-index:0;}.background1 {  background: url(https://picsum.photos/200/300?image=0);}.background2 {  background: url(https://picsum.photos/200/300?image=1069);}.backgroundFilter::before {  content:'';  position:absolute;  z-index:-1;  top:0;  left:0;  right:0;  bottom:0;  background: linear-gradient(to right,transparent,green);;}<div ><div >...</div><div >...</div><div >...</div><div >...</div></div>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/408086.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号