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;
}
相关推荐
兆子龙1 小时前
你不会使用 CSS 函数 clamp()?那你太 low 了😀
前端·javascript
兆子龙1 小时前
前端性能优化终极清单:从 3 秒到 0.5 秒的实战经验
前端·javascript
兆子龙1 小时前
babel-loader:让你的 JS 代码兼容所有浏览器
前端
百万蹄蹄向前冲1 小时前
支付宝 VS 微信 小程序差异
前端·后端·微信小程序
兆子龙1 小时前
JavaScript 的 Symbol.iterator:手写一个可迭代对象
前端
NGC_66111 小时前
ArrayList扩容机制
java·前端·算法
独泪了无痕6 小时前
使用Fetch API 探索前后端数据交互
前端·http·交互设计
css趣多多6 小时前
别名路径的知识点
前端
靓仔建8 小时前
Vue3导入组件出错does not provide an export named ‘user_setting‘ (at index.vue:180:10)
开发语言·前端·typescript