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;
}
相关推荐
梦曦i16 分钟前
@meng-xi/vite-plugin v0.1.5:告别手动 import,精简工具层
前端
梦曦i21 分钟前
Vite 0.1.6重磅更新:智能导入+路由安全
前端
gxf5203088069881 小时前
Flutter 裁剪图片
前端·app
ITMan彪叔1 小时前
赋能UE运行态编辑平台: 网络图片下载的插件改造与复盘
前端
RANxy1 小时前
🚀 Umi Max 项目从0到1:企业级 React 脚手架实战
前端·前端框架
拾年2751 小时前
深入理解 V8 引擎:从代码执行到垃圾回收的完整链路
前端·javascript·v8
Master_Azur1 小时前
javaScript进阶
前端
markfeng82 小时前
React入门教学
前端·react.js
ze_juejin2 小时前
Object.defineProperty vs Proxy 对比总结
前端
wing982 小时前
我的AI编程体验:从白嫖到付费,我为什么最终留下了Codex
前端·人工智能·程序员