Html代码:
<head>
<meta charset="UTF-8">
<title>MyBlog</title>
<link href="css/main.css" type="text/css" rel="stylesheet">
</head>
<body>
<div id="contain">
<div id="header"></div>
<div id="body"></div>
<div id="foot"></div>
</div>
</body>
main.css代码:
*{background-color:#09C}
*{margin:0px} /*去掉缝隙*/
/*星号,*代表整个页面的设置*/
#contain{background-color:#968;width:960px;height:400px;
margin-left:auto;margin-right:auto} /*margin-left/right:对象居中*/
#header{background-color:#3CF;width:960px;height:100px;}
#body{background-color:#30C;width:960px;height:200px;}
#foot{background-color:#FC3;width:960px;height:100px;}
效果:
实际上现在的网页多数都是大div套小div的
http://edu.51cto.com 来自51cto的教学