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.
精彩评论