2016-02-27 28 views
0

是否有任何理由使用HTML5樣板時,設立在CSS使用CSS背景圖像不顯示(使用HTML5樣板)

body { 
     background-image: url(../images/beach.png) no-repeat center center fixed; 
     -webkit-background-size: cover; 
     -moz-background-size: cover; 
     -o-background-size: cover; 
     background-size: cover; 
    } 

一個網站,我就不會加載圖像,但使用只是爲了

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

有效嗎?

回答

3

如果您使用background-image,你只能使用這個屬性來設置背景圖片。屬於其他屬性的值不能設置。在這種情況下,您正嘗試爲屬性不屬於background-image的屬性設置值。

如果您使用的是background屬性,則可以使用此屬性設置任何background相關屬性。

0

試試這個:

body { 
    background-image:url(../images/beach.png) center center fixed; 
    background-repeat:no-repeat; 
    // rest of your code 
} 
0

background-image是一個指令,只設置背景圖像的文件。 其它性能可以用這些指令來設置:

background-color background-image background-repeat background-attachment background-position

background僅是一個速記允許使用上面的一個或多個指令。

背景速記屬性設置一個聲明中的所有背景屬性。

More infos on w3school site

0

我猜你一定要用雙引號。 background-image:url(「paper.gif」);