我的问题看起来很愚蠢。但事实并非如此,即使我这么认为。
我在我的背景颜色上设置了一个渐变,以影响其下方位置固定的背景图像。
body{
background-image:url(...);
background-attachment: fixed;
}
body:after{
content: "";
display: block;
background-attachment: fixed;
position: absolute;
height: 100%;
width: 100%;
background: -moz-linear-gradient(-45deg, rgba(30,87,153,1) 0%, rgba(89,148,202,1) 62%, rgba(95,154,207,0.7) 68%, rgba(125,185,232,0) 100%);
}`
我希望,我已经够精确了。如果您需要更多信息,请不要犹豫。
谢谢!
最佳答案
如果这是你想要的:
- body 上的固定背景图片
- 还有一个固定的背景,遮住大部分背景图片
你需要添加
top:0; left:0;
z-index:-1;
到body::after
,并将其position:absolute
更改为position:fixed
。
z-index 是必需的,否则::after 将位于正文本身的内容之上。
参见 jsfiddle .
关于css - 如何修复背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17451220/