Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何固定背景色?_Css_Gradient_Background Color_Fixed - Fatal编程技术网

Css 如何固定背景色?

Css 如何固定背景色?,css,gradient,background-color,fixed,Css,Gradient,Background Color,Fixed,我的问题,可能看起来很愚蠢。但事实并非如此,即使我也这么认为 我有一个梯度在我的背景色,使背景图像的效果是在它下面的位置固定 body{ background-image:url(...); background-attachment: fixed; } body:after{ content: ""; display: block; background-attachment: fixed; position: absolute; height: 100%;

我的问题,可能看起来很愚蠢。但事实并非如此,即使我也这么认为

我有一个梯度在我的背景色,使背景图像的效果是在它下面的位置固定

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%);
}`
我希望,我已经足够精确了。如果你需要更多的信息,不要犹豫


谢谢大家!

如果这是您想要的:

  • 身体上的固定背景图像
  • 在上面有一个固定的背景,模糊了大部分的背景图像
您需要添加

top:0; left:0;
z-index:-1;
主体::after
,并将其
位置:绝对
更改为
位置:固定

z索引是必需的,因为否则::after将位于主体本身的内容之上


请参阅。

问题在于具体是什么?那么您想要实现什么?我只想在背景图像上加一个渐变。当我向下滚动的时候,没有什么可以抱怨的。我希望你能理解。