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;
}
相关推荐
10年前端老司机2 小时前
React无限级菜单:一个项目带你突破技术瓶颈
前端·javascript·react.js
阿芯爱编程6 小时前
2025前端面试题
前端·面试
前端小趴菜057 小时前
React - createPortal
前端·vue.js·react.js
晓13138 小时前
JavaScript加强篇——第四章 日期对象与DOM节点(基础)
开发语言·前端·javascript
菜包eo8 小时前
如何设置直播间的观看门槛,让直播间安全有效地运行?
前端·安全·音视频
烛阴8 小时前
JavaScript函数参数完全指南:从基础到高级技巧,一网打尽!
前端·javascript
chao_7899 小时前
frame 与新窗口切换操作【selenium 】
前端·javascript·css·selenium·测试工具·自动化·html
天蓝色的鱼鱼10 小时前
从零实现浏览器摄像头控制与视频录制:基于原生 JavaScript 的完整指南
前端·javascript
三原10 小时前
7000块帮朋友做了2个小程序加一个后台管理系统,值不值?
前端·vue.js·微信小程序
popoxf10 小时前
在新版本的微信开发者工具中使用npm包
前端·npm·node.js