全屏幕背景颜色css3

问题描述:

enter image description here我有一个渐变作为背景颜色,但它只是重复。我希望渐变伸展到全屏,因此无法缩小并查看任何空白区域或重复的渐变。全屏幕背景颜色css3

这里是我的身体

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 */ 
} 
+0

你有没有尝试设置'{HTML身高:100%; ''? – hsan 2013-02-18 14:41:15

+0

@hsan在缩小时适用,但现在放大时会重复渐变。我会上传一张图片,以便您可以看到现在发生了什么。 – 2013-02-18 14:43:37

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

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

工作过。非常感谢你。 – 2013-02-18 14:49:24

我粘贴你的代码测试页,CSS和它似乎是在做你想要什么。如果您遇到问题,也许您可​​以尝试添加background-size: 100%;

希望它有帮助。

+0

我已经发布了现在放大时的外观。代码无法正常工作。 – 2013-02-18 14:46:45