2013-02-18 103 views
3

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

回答

9

嘗試設置上body的高度和寬度,並嘗試使用background-attachment

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

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

2

我粘貼你的代碼測試頁,CSS和它似乎是在做你想要什麼。如果您遇到問題,也許您可​​以嘗試添加background-size: 100%;

希望它有幫助。

+0

我已經發布了現在放大時的外觀。代碼無法正常工作。 – 2013-02-18 14:46:45