2014-05-13 56 views
0

我使用的CSS文件CSS3整個頁面的背景圖像顯示低於體溫

html { 
    background: url(images/background.jpg) no-repeat center center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
} 

以下雖然它似乎很好地試圖建立一個完整的頁面背景圖片,它只出現在下面的出現在任何主體(如頁腳)

任何幫助,將不勝感激 問候,loaannis

回答

0

也許你沒有設置你的div的權利: 在這裏我要給你一個示例代碼,包括「主要內容」迪v和「身體」標籤內的「頁腳」分區:

HTML:

<body> 
    <div id="main-content"> 
     <p>1234 testing 1234</p> 
     <p>main content goes here</p> 
     <p>4321 testing 4321</p> 
    </div> 
    <div id="footer"> 
     <p>Contact information here</p> 
    </div> 

</body> 

,這是一個額外的行確定頁腳顏色的CSS(爲了更好的可見性):

body { 
background: url("http://www.neyralaw.com/wp-content/uploads/2012/07/tokyo-blue-background-4547.jpg") no-repeat center center fixed; 
-webkit-background-size: cover; 
-moz-background-size: cover; 
-o-background-size: cover; 
background-size: cover; 
} 
#main-content {color:yellow;} 
#footer {position:absolute; bottom:0; color:white;} 

請注意,爲了獲得更好的可見性,我已將您的本地圖像網址替換爲我在互聯網上找到的圖像。當然,任何圖片網址都會正確顯示。我也用css中的「body」取代了「html」。既然「身體」是它實際上「顯示」,我不明白爲什麼你應該風格的「HTML」。但是,即使在CSS中body替換爲html,它仍然可以正常工作!

演示在這裏:http://jsfiddle.net/Ee74C/4/

快樂編碼,

Thodoris

+0

感謝您的反饋意見。 「身體」做了詭計。出於教學原因,不應該「html」的工作一樣好? – Ioannis

+0

@Ioannis某些瀏覽器(如IE(8,9))可能會忽略頭部樣式。正如我通常喜歡風格的身體,我不能爲您提供樣式HTML或正文之間的具體區別。不過,我想你可能會發現這篇文章很有用:http://stackoverflow.com/questions/8958458/css-styling-body-element-vs-styling-html-element Καλήσυνέχεια! –