基本的想法是让包装器根据孩子的身高自动扩展高度。问题是菜单子有浮动attr,如果它比内容大 - 它只是伸出,你可以通过加载代码看到。 我不喜欢玩相对位置,表格单元格..如果我设置浮动:左边的包装器它实际上因为某些原因而错误我的整个标记。 还有其他办法吗?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
div.wrap{
background-color:grey;
padding:5px;
}
div.left{
background-color:orange;
float:left;
width:200px;
height:400px;
}
div.content{
margin-left:200px;
height:200px;
background-color:white;
}
</style>
</head>
<body>
<div class="wrap">
<div class="left">
Menu
</div>
<div class="content">
Text
</div>
</div>
</body>
</html>
答案 0 :(得分:2)
内部div.wrap
:
<div class="clear"></div>
内部<style>
:
div.clear{
clear:both;
}