2011-11-21 83 views
-1

可能重複:
Fit background image to div如何使背景圖像適合div?

如何使用DIV使背景圖像適應,因爲在Firefox中,有一點問題都沒有,不像IE8,IE9

這裏是代碼

div.helpcontent{ 
    height:120px; 
    display:none; 
    width: 300px; 
    position: relative; 
    z-index: 1000000; 
} 


div.helpcontent{ 
    margin: 0 15px; 
    padding: 5px; 
    width: 242px; 
    text-align: center; 
    //background: #ffffff; 
    background: url(../images/helpBg.gif) no-repeat; 
    border: solid 1px #000000; 
} 
+1

你是什麼意思「適合div」 – CommunistPancake

回答

1

在CSS3中,您可以使用以下css:

div.helpcontent 
{ 
    background:url(../images/helpBg.gif); 
    -moz-background-size:100% 100%; /* Firefox 3.6 */ 
    background-size:100% 100%; 
    background-repeat:no-repeat; 
    border: solid 1px #000000; 
    padding: 5px; 
    text-align: center; 
}