CSS頭部內容和底部佈局效果

antzone發表於2017-04-12

分享一段程式碼例項,它簡單演示了網站常見的上中下佈局效果。

也就是頭部、內容部分和底部佈局,程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
body {
  padding: 0px;
  margin: 0px;
  font-size: 30px;
}
div {
  text-align: center;
}
.top, #s, .left, .right, .bottom {
  width: 600px;
  margin: 0 auto;
}
.top {
  border: 1px solid #069;
  height: 100px;
  background: #96F;
}
#s {
  width: 600px;
  margin: 0 auto;
}
.left {
  width: 150px;
  height: 800px;
  background: pink;
  float: left;
  border: 1px solid #069;
}
.right {
  width: 150px;
  height: 800px;
  background: yellow;
  float: right;
  border: 1px solid #069;
}
.middle {
  height: 800px;
  background: red;
  border: 1px solid #069;
  margin: 0 180px 0 180px;
}
.bottom {
  height: 100px;
  background: green;
  border: 1px solid #069;
}
</style>
</head>
<body>
  <div class="top">top</div>
  <div id="s">
    <div class="left">left</div>
    <div class="right">right</div>
    <div class="middle">middle</div>
  </div>
  <div class="bottom">bottom</div>
</body>
</html>

相關文章