HTML/CSS-线性渐变不占用全屏

HTML/CSS-线性渐变不占用全屏,html,css,background,gradient,linear-gradients,Html,Css,Background,Gradient,Linear Gradients,如果我的身体具有以下CSS属性: body { background-color: red; background-image: linear-gradient(red, orange); } 然后渐变出现在我的网页上,但它不占全屏大小(我有一个大显示器)。如下所示:这是页脚的问题吗?我目前没有页脚 试试这个 body, html { height: 100%; width: 100%; } body { background: rgba(231,56,39,1);

如果我的身体具有以下CSS属性:

body {

 background-color: red;
 background-image: linear-gradient(red, orange);
}
然后渐变出现在我的网页上,但它不占全屏大小(我有一个大显示器)。如下所示:这是页脚的问题吗?我目前没有页脚

试试这个

body, html {
  height: 100%;
  width: 100%;
}

body {
  background: rgba(231,56,39,1);
  background: -moz-linear-gradient(top, rgba(231,56,39,1) 0%, rgba(231,56,39,1) 27%, rgba(255,166,0,1) 100%);
  background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(231,56,39,1)), color-stop(27%, rgba(231,56,39,1)), color-stop(100%, rgba(255,166,0,1)));
  background: -webkit-linear-gradient(top, rgba(231,56,39,1) 0%, rgba(231,56,39,1) 27%, rgba(255,166,0,1) 100%);
  background: -o-linear-gradient(top, rgba(231,56,39,1) 0%, rgba(231,56,39,1) 27%, rgba(255,166,0,1) 100%);
  background: -ms-linear-gradient(top, rgba(231,56,39,1) 0%, rgba(231,56,39,1) 27%, rgba(255,166,0,1) 100%);
  background: linear-gradient(to bottom, rgba(231,56,39,1) 0%, rgba(231,56,39,1) 27%, rgba(255,166,0,1) 100%);

}

答案实际上是保证金属性

body, html {
  height: 100%;
  width: 100%;
  margin: 0;
}

遇到同样的问题,但只有这个问题有效,请将此样式添加到css中

background-attachment: fixed;
background attachment
属性设置背景图像是与页面的其余部分一起滚动,还是固定。有三个值:
滚动
固定
,和
本地
。在渐变背景下效果最好


查看文档

中间的白色正方形是什么?只是一堆内容我在油漆上画了一个白色正方形。我认为渐变只与页面主体的背景有关。请发布您完成的代码或提供一个演示。这实际上有效+1