最近在学习了html5,学习了<div>和<table>常见的两种布局:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>div布局</title>
<style type="text/css">
body{
margin: 0px;
}
#container{
width: 100%;
height: 950px;
background: gray;
}
#heading{
width: 100%;
height: 10%;
background: red;
}
#context_menu{
width: 20%;
height: 80%;
background: greenyellow;
float: right;
}
#context_body{
width: 80%;
height: 80%;
background: chartreuse;
float: left;
}
#footing{
width: 100%;
height: 10%;
background: darkgreen;
}
</style>
</head>
<body>
<div id="container">
<div id="heading">头部</div>
<div id="context_menu">内容菜单</div>
<div id="context_body">内容主体</div>
<div id="footing">底部</div>
</div>
</body>
</html>
table的布局:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>table布局</title>
</head>
<body marginwidth="0px" marginheight="0px">
<table width="100%" height="950px" style="background-color: gray">
<tr>
<td colspan="2" width="100%" height="10%" style="background-color: red">这是头部</td>
</tr>
<tr>
<td width="20%" height="80%" style="background-color: aqua">左菜单</td>
<td width="80%" height="80%" style="background-color: darkgreen"></td>
</tr>
<tr>
<td width="100%" height="10%" style="background-color: darkred" colspan="2">这是底部</td>
</tr>
</table>
</body>
</html>