2012-12-03 26 views
0

如何設置背景圖像以適應不帶css定位的屏幕尺寸?我在做學校工作,我想設置一個背景圖片,但我的教授說我不能使用定位,所以有另一種方式呢?如何設置背景圖像以適應沒有css定位的屏幕尺寸?

+3

你可以使用_background positioning_?這是一個奇怪的限制。 –

+0

這已被問:http://stackoverflow.com/questions/376253/stretch-and-scale-css-background – Dave

+0

不,我不能使用任何東西,包括位置 –

回答

2

試試這個

html{ 
    background:url('backgroundimage.jpg') no-repeat center center; 
    min-height:100%; 
    min-width:100%; 
    background-size:cover; 
} 

body{ 

    min-height:100%;/*hack for some mobile browsers */ 
    min-width:100%; 
} 

reference link

相關問題