【问题标题】:how to make the background image fit with the div? [duplicate]如何使背景图像适合 div? [复制]
【发布时间】:2012-01-02 17:06:34
【问题描述】:

可能重复:
Fit background image to 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;
}

【问题讨论】:

  • “适合 div”是什么意思

标签: html css internet-explorer


【解决方案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;
}

【讨论】: