网站通常会显示多个列的内容(like a magazine or newspaper) 。
城市规划展览馆
伦敦
巴黎
东京
巴黎
东京
伦敦
伦敦是英国的首都城市。 它是英国人口最多的城市,有超过13万居民的大都市区。
站在泰晤士河,伦敦一直是主要解决两两千年来,它的历史可以追溯到罗马人,谁把它命名为伦迪尼乌姆成立。
版权所有©w3ii.com
HTML布局使用<div>元素
所述<div>元件经常被用来作为布局的工具,因为它可以很容易地定位成与CSS。
此示例使用四个<div>元素来创建多列布局:
例
<body>
<div id="header">
<h1>City Gallery</h1>
</div>
<div id="nav">
London<br>
Paris<br>
Tokyo
</div>
<div id="section">
<h1>London</h1>
<p>London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.</p>
<p>Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.</p>
</div>
<div id="footer">
Copyright © w3ii.com
</div>
</body>
试一试» CSS的:
<style>
#header {
background-color:black;
color:white;
text-align:center;
padding:5px;
}
#nav {
line-height:30px;
background-color:#eeeeee;
height:300px;
width:100px;
float:left;
padding:5px;
}
#section {
width:350px;
float:left;
padding:10px;
}
#footer {
background-color:black;
color:white;
clear:both;
text-align:center;
padding:5px;
}
</style>
网站布局使用HTML5
HTML5提供了定义网页的不同部分新的语义元素:
|
此示例使用<header> , <nav> <section> ,和<footer>创建多列布局:
例
<body>
<header>
<h1>City Gallery</h1>
</header>
<nav>
London<br>
Paris<br>
Tokyo
</nav>
<section>
<h1>London</h1>
<p>London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.</p>
<p>Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.</p>
</section>
<footer>
Copyright © w3ii.com
</footer>
</body>
试一试» CSS的:
<style>
header {
background-color:black;
color:white;
text-align:center;
padding:5px;
}
nav {
line-height:30px;
background-color:#eeeeee;
height:300px;
width:100px;
float:left;
padding:5px;
}
section {
width:350px;
float:left;
padding:10px;
}
footer {
background-color:black;
color:white;
clear:both;
text-align:center;
padding:5px;
}
</style>
HTML布局使用表
所述<table>元素没有被设计成为一个布局工具。
所述的目的<table>元素是显示表格数据。
布局可以使用取得的<table>元素,因为表元素可以与CSS设置样式:
例
<body>
<table class="lamp">
<tr>
<th>
<img src="../images/lamp.jpg" alt="Note" style="height:32px;width:32px">
</th>
<td>
The table element was not designed to be a layout tool.
</td>
</tr>
</table>
</body>
试一试» CSS的:
<style>
table.lamp {
width:100%;
border:1px solid #d4d4d4;
}
table.lamp th, td {
padding:10px;
}
table.lamp th {
width:40px;
}
</style>
警告:表的创建布局并没有错,但不建议吧! 避免创建布局表格。