2010-11-30 44 views

回答

0

本網站http://css-tricks.com/how-to-resizeable-background-image/在這方面有很好的體會。

基本上只是作爲樣式使用您的BG

#bg { 
    width: 100%; 
    position: absolute; 
    top: 0; 
    left: 0; 
} 

關於您的要求,以保持縱橫比AT的同時,使之覆蓋整個窗口,我不認爲這是可以實現的,你要麼犧牲長寬比或覆蓋

+0

你好,好的,謝謝!我試圖用JavaScript實現它,但沒有結果。 – PPPHP 2010-11-30 07:12:00

0

試試這個代碼通過jQuery的

var docHeight = Math.max(

      $(document).height(), 

      $(window).height(), 

      /* For opera: */ 

      document.documentElement.clientHeight 

     ); 

     var docWidth = Math.max(

      $(document).width(), 

      $(window).width(), 

      /* For opera: */ 

      document.documentElement.clientWidth 

     ); 

     $("selector").css({ 

      "height":docHeight, 

      "width":docWidth 

     });