css一些注意事项

css一些注意事项

css 复制代码
.bg_ {
		background-image: url('/static/photo/activity_bg.png');
		background-size: 100% auto;
		background-repeat: no-repeat;
		background: linear-gradient(to bottom, #CADCEA, #E8F3F6);
		min-height: 100vh;
}

背景图片路径正确但是并没有显示

css 复制代码
// 方案1:将图片和渐变合并到同一个 background 属性中
background: 
    linear-gradient(to bottom, #CADCEA, #E8F3F6),
    url('/static/photo/activity_bg.png') no-repeat;
background-size: 100% auto;

// 方案2:使用 background-image 同时声明图片和渐变
background-image: 
    linear-gradient(to bottom, #CADCEA, #E8F3F6),
    url('/static/photo/activity_bg.png');
background-size: 100% auto;
background-repeat: no-repeat;

背景图片没有显示的原因是因为 background 属性覆盖了 background-image。在CSS中,background 是一个复合属性,当你使用它时,会重置所有其他背景相关的属性(包括 background-image)。

相关推荐
快乐肚皮19 分钟前
深入理解Loop Engineering
前端·后端
风骏时光牛马38 分钟前
VHDL十大经典基础功能设计实例代码合集
前端
hunterandroid1 小时前
Notification 通知:从基础到渠道适配
前端
孟陬1 小时前
Claude Code 巧思 `Ctrl+S` 暂存键
前端·后端
PedroQue991 小时前
V1.6.1性能优化:高频路径提速与代码精简
前端·uni-app
猩猩程序员1 小时前
将 LiteLLM 迁移到 Rust —— 构建最快、最轻量的 AI Gateway
前端
lichenyang4531 小时前
JSBridge 分发升级:为什么要从 if-else 变成 Registry > 这是「ASCF 架构升级」系列的第 3 篇
前端
码上天下1 小时前
流式响应断了,前端怎么自动重连续传
前端
anyup1 小时前
来简单聊聊鸿蒙开发,万元奖金的事~
前端·华为·harmonyos
北凉温华2 小时前
Univer 在线表格模块使用说明
前端