全屏背景颜色css3

新手上路,请多包涵

在此处输入图像描述我有一个渐变作为背景颜色,但它只是重复。我希望渐变拉伸到全屏,这样就不可能缩小并看到任何空白或重复的渐变。

这是我的身体的CSS

 body {
text-align:center;
background: rgb(238,238,238); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(238,238,238,1) 0%, rgba(89,89,89,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(238,238,238,1)), color-stop(100%,rgba(89,89,89,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(238,238,238,1) 0%,rgba(89,89,89,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(238,238,238,1) 0%,rgba(89,89,89,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(238,238,238,1) 0%,rgba(89,89,89,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(238,238,238,1) 0%,rgba(89,89,89,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#595959',GradientType=0 ); /* IE6-9 */
}

原文由 Lawrence Smith 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 298
2 个回答

尝试在 body 上设置高度和宽度,并尝试使用 background-attachment

 html, body
{
    width: 100%;
    height: 100%;
}
body
{
    …
    width: 100%;
    height: 100%;
    background-attachment: fixed;
}

原文由 user1640263 发布,翻译遵循 CC BY-SA 3.0 许可协议

我将您的代码粘贴到测试页中,它似乎完全符合您的要求。如果您遇到问题,也许您可以尝试添加 background-size: 100%;

希望能帮助到你。

原文由 Dvir Levy 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏