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;
}
相关推荐
奔跑的web.1 小时前
TypeScript 装饰器入门核心用法
前端·javascript·vue.js·typescript
winfredzhang2 小时前
实战复盘:如何用 HTML+JS+AI 打造一款“影迹”智能影视管理系统
javascript·html·json·加载·搜索·保存·电影接口
集成显卡2 小时前
Lucide Icons:一套现代、轻量且可定制的 SVG 图标库
前端·ui·图标库·lucide
pas1362 小时前
37-mini-vue 解析插值
前端·javascript·vue.js
十里-3 小时前
vue.js 2前端开发的项目通过electron打包成exe
前端·vue.js·electron
雨季6664 小时前
构建 OpenHarmony 简易文字行数统计器:用字符串分割实现纯文本结构感知
开发语言·前端·javascript·flutter·ui·dart
小北方城市网4 小时前
Redis 分布式锁高可用实现:从原理到生产级落地
java·前端·javascript·spring boot·redis·分布式·wpf
console.log('npc')4 小时前
vue2 使用高德接口查询天气
前端·vue.js
2401_892000524 小时前
Flutter for OpenHarmony 猫咪管家App实战 - 添加支出实现
前端·javascript·flutter
天马37984 小时前
Canvas 倾斜矩形绘制波浪效果
开发语言·前端·javascript