div布局
原理
利用div自定义标签(嵌套)实现对网页的布局
简单div布局的代码实现
<head>
<meta charset="UTF-8">
<title>div布局</title>
<style type="text/css">
div#container{
width: 100%;
height: 950px;
background: antiquewhite;
}
div#heading{
width: 100%;
height: 10%;
background: cyan;
}
div#content-menu{
width: 30%;
height: 80%;
background: blueviolet;
float: left;
}
div#content-body{
width: 70%;
height: 80%;
background: forestgreen;
float: right;
}
div#footing{
width: 100%;
height: 10%;
background: gold;
}
</style>
</head>
<body>
<div id="container">
<div id="heading">
头部
</div>
<div id="content-menu">
内容菜单
</div>
<div id="content-body">
内容主体
</div>
<div id="footing">
底部
</div>
</div>
</body>
div#container{ // 注: div可省略,直接#container
width: 100%;
height: 950px;
background: antiquewhite;
}
##简单div布局的效果展示
可以看出,table布局和div布局没啥太大区别,只是布局的两种形式罢了