2011-11-21 104 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; 
}