HTML布局
1、<div>元素布局
我们一般最先想到的一个网页的结构是
头部+内容菜单+主体+底部
因此我们可以先定义
<span style="font-size:14px;"><body>
<div id="container">
<div id="heading">头部</div>
<div id="content_menu">内容菜单</div>
<div id="content_body">内容主体</div>
<div id="footing">底部</div>
</div>
</body></span>
<span style="font-size:14px;"><!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-color:#999999;
}
#heading{
width:100%;
height:10%;
background-color:#00FFFF;
}
#content_menu{
width:30%;
height:80%;
background-color:#FFFF00;
float:left;}
#content_body{
width:70%;
height:80%;
background-color:#FF3300;
float:left;}
#footing{
width:100%;
height:10%;
background-color:#000000;
clear:both;}
</style>
</head>
<body>
<div id="container">
<div id="heading">
<h1>这是头部</h1>
</div>
<div id="content_menu">内容菜单</div>
<div id="content_body">内容主体</div>
<div id="footing">底部</div>
</div>
</body>
</html></span>
这样就可以得到我们想要的几个部分,至于中间的内容及具体样式,可再具体化代码。
2、<table>元素布局
布局也可以用<table>布局
<span style="font-size:14px;color:#333333;"><!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>table布局</title>
</head>
<body marginheight="0px" marginwidth="0px">
<table width="100%" height="950px" style="background-color:#999999">
<tr>
<td colspan="2" width="100%" height="10%" style="background-color:#FF0000">这是头部</td>
</tr>
<tr>
<td width="30%" height="80%" style="background-color:#0033CC">左菜单</td>
<td width="70%" height="80%" style="background-color:#FF00FF">右菜单</td>
</tr>
<tr>
<td width="100%" height="10%" colspan="2" style="background-color:#FF0000">这是底部</td>
</tr>
</table>
</body>
</html>