html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3行1列title>
<style>
*{
margin: 0;
padding: 0;
}
#container {
margin:0 auto;
width:900px;
height:500px;
}
#header {
height:100px;
background:#6cf;
margin-bottom:5px;
}
#main{
height:500px;
background:#cff;
margin-bottom:5px;
}
#footer {
height:60px;
background:#6cf;
}
style>
head>
<body>
<div id="container">
<div id="header">
div>
<div id="main">
div>
<div id="footer">
div>
div>
body>
html>
友友们,对于这样的一段语言,父盒子的高度一开始是500像素,随着herder和main、footer高度的增加,最后盒子的高度应该是670个像素对吗?
设置了 container 的高度,它就不会自动增加,还是500px,如果不设置的话,默认他是会随内部元素增高而增高
#container {
margin:0 auto;
width:900px;
height:500px;
}
container 的高度还是500,如果你加个overflow:hidden,里面的子盒子高度超过500的就会被隐藏,如果不加这个,不会隐藏,但container 的高度还是500
#container应该还是500
你要想高度是670可以把#container高度删掉试试