2014-02-08 75 views

回答

1

CSS3 背景大小可以在這裏使用。

background-size: [auto|percentage|units - for width] [auto|percentage|units - for height]; 

例如:

.bg{ 
    /*will stretch the element's background to its full width (saving proportions of the picture - so it may be cut vertically or not fill the entire height):*/ 
    background-size:100% auto; 

    /*will stretch the element's background to its full height (it may be cut - this time - horizontally or not fill the entire width):*/ 
    background-size:auto 100%; 

    /* the background will be forced to the 50% of the el's width and 40% of its height respectively: */ 
    background-size:50% 40%; 
} 
+0

Wait.Let我嘗試 – user3274745

+0

能否請您詳細闡述。上面的代碼應該被粘貼,或者我必須添加一些東西 – user3274745

+0

@ user3274745添加了幾個例子。 – bonflash