开发者

css div in div incorrect height

I would like the container div to resize to its con开发者_Go百科tents (content div). It doesn't.

example.html:

<html>
    <head>
        <link href="example.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
        <hr/>
        <div class="container">
            <div class="content">
            lorem ipsum
            </div>
        </div>
        <hr/>
    </body>
</html>

example.css:

.container
{
    border-style: solid;
    position: relative;
}

.content
{
    border-style: dashed;
    position: absolute;
}

Regards!


I believe it is because your contents position is absolute. I think that pretty much destroys the parents influence in this context. Try commenting out that line and see if it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜