直接上代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>九宫格布局</title>
<style>
body{
width:100%;
height:100%;
margin:0;
padding:0;
}
#main{
margin:5px auto;
width:100%;
height:100%;
}
#main div{
background-color:#0f0;
float:left;
width:33%;
height:150px;
line-height:150px;
margin-right:-1px;
margin-bottom:-1px;
border:1px solid red;
box-sizing:border-box;
text-align:center;
}
</style>
</head>
<body>
<div id="main">
<div>区域1</div>
<div>区域2</div>
<div>区域3</div>
<div>区域4</div>
<div>区域5</div>
<div>区域6</div>
<div>区域7</div>
<div>区域8</div>
<div>区域9</div>
</div>
</body>
</html>
说明:
margin-right:-1px; 代表右侧无边框
margin-bottom:-1px; 代表底部无边框