div问题:高度不随内容扩展

Tho*_*ohn 5 html css xhtml

我正在尝试使用CSS创建一个网页(表少)但我的主要内容区域没有扩展内容请检查我的HTML和CSS代码,并给我一个解决方案,谢谢

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="style/styles.css" type="text/css" />
<title>::Model::</title>
</head>
<body>
<div id="wrapper">
<div id="header">
header
</div>
<div id="main">
<div id="left">left</div>
<div id="right">right</div>
</div>
<div id="footer">
footer
</div>

</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

Css代码

body{
    margin:0px;
    padding:0px;
    height:auto;
}

#wrapper{
    margin:0px auto;
    width:1000px;
}

#header{
height:50px;
border:#CCCCCC solid 1px;
margin:2px;
padding:5px;
}

#main{
height:auto;
border:#CCCCCC solid 1px;
margin:2px;
padding:5px;

}

#footer{
height:100px;
border:#CCCCCC solid 1px;
margin:2px;
padding:5px;
}

#left{
border:#CCCCCC solid 1px;
width:640px;
padding:4px;
float:left;

margin-right:2px;

}
#right{
float:right;
padding:4px;

border:#CCCCCC solid 1px;
width:320px;


}
Run Code Online (Sandbox Code Playgroud)

再次感谢

Mat*_*Cat 9

只要申请overflow:auto;#main让它包裹它的流动儿童.看看左边的浮动图像更改容器div的高度

(你可以删除它的height规则)