css中背景色、背景图的使用

1、同时使用背景色、背景图片

参考链接:链接

以下样式,背景色在图片下方(缺点:图片不透明时,背景色会被完全遮挡。)

复制代码
.header {
	height: 100%;
	width: 100%;
	background-color: #000;
	background-image: url('/static/images/back.png') ;
	background-repeat: no-repeat;
	background-size: 100% 100%;
}

2、两张图片叠加

参考链接:链接

复制代码
<view class="header">
	<view class="header-box"></view>
</view>

.header {
	height: 100%;
	width: 100%;
	background-image: url('/static/images/back.png') ;
	background-repeat: no-repeat;
	background-size: 100% 100%;
	position: relative;
	.header-box{
		position: absolute;
		top: 0;
		bottom: 0;
        left:0;
        right:0;
		background: url('/static/images/back1.png') ;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		mix-blend-mode: overlay;
	}
}

底图:

遮罩图 :

合成图:

3、多张图片平铺

参考链接:链接

原图:

横向平铺:

复制代码
.header {
	height: 80vh;
	width: 100%;
	background: url('/static/images/index_after.png') center left no-repeat,
		url('/static/images/index_after.png') center right no-repeat,
		url('/static/images/index.png') center left repeat-x;
}

纵向平铺:

复制代码
.header {
	height: 80vh;
	width: 100%;
	background: url('/static/images/index_after.png') center top no-repeat,
	    url('/static/images/index_after.png') center bottom no-repeat,
		url('/static/images/index.png') center top repeat-y;
}
相关推荐
lxh01133 分钟前
二叉树中的最大路径和
前端·算法·js
CC码码34 分钟前
前端字符串排序搜索可以更加细化了
前端·javascript·面试
喵爱吃鱼35 分钟前
kuma-ui中Flex vs FlexMin的关键区别
前端
codingMan37 分钟前
[Android Compose] 拒绝闪烁!打造丝滑的聊天页面列表(仿微信效果)
前端
你别追我跑不动39 分钟前
基于代码扫描的 Icon 优化实践
前端·性能优化
磊磊磊磊磊40 分钟前
用AI做了个排版工具,分享一下如何高效省钱地用AI!
前端·后端·react.js
喵爱吃鱼41 分钟前
flex 0 flex 1 flex none flex auto 应该在什么场景下使用
前端
雾散声声慢43 分钟前
解决 iOS 上 Swiper 滑动图片闪烁问题:原因分析与最有效的修复方式
前端·css·ios
Crystal3281 小时前
冒泡排序 bubble sort
前端·javascript·面试
阿蓝灬1 小时前
clientWidth vs offsetWidth
前端·javascript