-1

如何使用 css 根据其内容水平拉伸图像。 替代文字

//html code

        <style>
html, body{
    margin: 0;
    padding: 0;

}


    #cont {
    width:100%;
    height:125px;

    background-color:#1ea1de;
    }

    .logo {
        height:100px;
        width:300px;
        background: url(logo3.png) no-repeat;
        margin-top:-105px;
    }
    #liniq {
        height:2.5px;
        width:100%;
        background-color: #b5babc;
        margin-top:5px;
    }
    #levo {
        background: url(levo.gif) no-repeat;
        width:64px;
        height:104px;
        margin-left:280px;
        margin-top:-170px;

    }
    #middle {
        background:url(middle.gif) repeat-x;
        height:41px;
        margin-top:-62px;
        margin-left:321px;
        border:1px solid red;
        overflow:hidden;

    }
</style>
</head>

<body>

<div id="cont"></div>
<div class="logo"></div>
<div id="liniq"></div>

<div id="buttons">

<div id="levo"></div>
<div id="middle"></div>
</div>
</body>
</html>

但它不会根据内容拉伸......

4

1 回答 1

1

我看不懂图片,但您似乎正在尝试拉伸背景图像,如果不使用 CSS3 属性background-size ,这是不可能的。

无论如何,您可以将图像放在 html appliyingwidth:100%中,它的高度将自动调整大小。

(并且width:100%对块元素没用)

于 2010-12-30T08:18:01.470 回答