div+css布局使用inline-block

來源:互聯網
上載者:User

標籤:

參考自:http://zhidao.baidu.com/link?url=xtKe0RtLKDa1TZGais49zDuAaja1yGGZVV9zd9qJENV7HrRnd6lls90SW7EQXA3e0tZY3MHLeGiTSQdKHYMrHK

 

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>測試</title>
<link rel="stylesheet" type="text/css" href="css.css">
</head>
<body>
<div class="h">頂部層</div>
<div class="nav">導覽列</div>
<div class="l">廣告層</div>
<div class="m">頁面主體</div>
<div class="r">廣告層</div>
<div class="b">底部層</div>
</body>
</html>

css.css 內容如下:

html, body { height:100%; padding:0px; margin:0px; }
.h, .nav, .l, .m, .r, .b { text-align:center; font-size:14px; border:1px solid #000000; margin:-1px;}
.h { height:10%;}
.nav { height:5%; background-color:#5C69C2;}
.l { float:left; width:20%; height:70%; }
.r { float:right; width:20%; height:70%; }
.m { float:left; width:60%; height:70%;}
.b { clear:both; height:10%; }




改動後使用inline-block布局

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>測試</title>
<style type="text/css">
html, body { height:100%; padding:0px; margin:0px; font-size: 0;}
.h, .nav, .l, .m, .r, .b { text-align:center; font-size:14px; }
.h { height:10%;}
.nav { height:5%; background-color:#5C69C2;}
.l { width:20%; height:70%; display: inline-block;}
.r { width:20%; height:70%; display: inline-block;}
.m { width:60%; height:70%;display: inline-block;}
.b { clear:both; height:10%; }
.h div,.nav div,.l div,.m div,.r div,.b div{
border-top:1px solid #000;
height: 100%;
}
.h div:first-child{
border:none;
}
</style>
</head>
<body>
<div class="h"><div>頂部層</div></div>
<div class="nav"><div>導覽列</div></div>
<div class="l"><div>廣告層</div></div>
<div class="m"><div>頁面主體</div></div>
<div class="r"><div>廣告層</div></div>
<div class="b"><div>底部層</div></div>
</body>
</html>

div+css布局使用inline-block

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.