国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

characters

HTML 布局

網(wǎng)頁(yè)布局對(duì)改善網(wǎng)站的外觀非常重要。

請(qǐng)慎重設(shè)計(jì)您的網(wǎng)頁(yè)布局。

親自試一試 - 實(shí)例

使用 <div> 元素的網(wǎng)頁(yè)布局

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<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>
</head>

<body>

<div id="header">
<h1>City Gallery</h1>
</div>

<div id="nav">
London<br>
Paris<br>
Tokyo<br>
</div>

<div id="section">
<h2>London</h2>
<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 ? PHP中文網(wǎng).cn
</div>

</body>
</html>

使用 <div> 元素的網(wǎng)頁(yè)布局的效果:

KSVKT9ET5LAJSST25U_{6)V.png

使用 <table> 元素的網(wǎng)頁(yè)布局

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<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>
</head>

<body>

<div id="header">
<h1>City Gallery</h1>
</div>

<div id="nav">
London<br>
Paris<br>
Tokyo<br>
</div>

<div id="section">
<h2>London</h2>
<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 ? PHP中文網(wǎng)
</div>

</body>
</html>

實(shí)際上是不可以用<table>做為布局的

網(wǎng)站布局

大多數(shù)網(wǎng)站會(huì)把內(nèi)容安排到多個(gè)列中(就像雜志或報(bào)紙那樣)。

可以使用 <div> 或者 <table> 元素來(lái)創(chuàng)建多列。CSS 用于對(duì)元素進(jìn)行定位,或者為頁(yè)面創(chuàng)建背景以及色彩豐富的外觀。

提示:即使可以使用 HTML 表格來(lái)創(chuàng)建漂亮的布局,但設(shè)計(jì)表格的目的是呈現(xiàn)表格化數(shù)據(jù) - 表格不是布局工具!

HTML 布局 - 使用 <div> 元素

div 元素是用于分組 HTML 元素的塊級(jí)元素。

下面的例子使用五個(gè) div 元素來(lái)創(chuàng)建多列布局:

實(shí)例

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<style type="text/css">
div#container{width:500px}
div#header {background-color:#99bbbb;}
div#menu {background-color:#ffff99; height:200px; width:100px; float:left;}
div#content {background-color:#EEEEEE; height:200px; width:400px; float:left;}
div#footer {background-color:#99bbbb; clear:both; text-align:center;}
h1 {margin-bottom:0;}
h2 {margin-bottom:0; font-size:14px;}
ul {margin:0;}
li {list-style:none;}
</style>
</head>

<body>

<div id="container">

<div id="header">
<h1>Main Title of Web Page</h1>
</div>

<div id="menu">
<h2>Menu</h2>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</div>

<div id="content">Content goes here</div>

<div id="footer">Copyright PHP中文網(wǎng)</div>

</div>

</body>
</html>

上面的 HTML 代碼會(huì)產(chǎn)生如下結(jié)果:

66CG3RI0{7310VBJCXA49)U.png

HTML 布局 - 使用表格

使用 HTML <table> 標(biāo)簽是創(chuàng)建布局的一種簡(jiǎn)單的方式。

可以使用 <div> 或者 <table> 元素來(lái)創(chuàng)建多列。CSS 用于對(duì)元素進(jìn)行定位,或者為頁(yè)面創(chuàng)建背景以及色彩豐富的外觀。

提示:即使可以使用 HTML 表格來(lái)創(chuàng)建漂亮的布局,但設(shè)計(jì)表格的目的是呈現(xiàn)表格化數(shù)據(jù) - 表格不是布局工具!

下面的例子使用三行兩列的表格 - 第一和最后一行使用 colspan 屬性來(lái)橫跨兩列:

實(shí)例

<!DOCTYPE html>
<html>
<meta charset="utf-8">
<body>

<table width="500" border="0">
<tr>
<td colspan="2" style="background-color:#99bbbb;">
<h1>Main Title of Web Page</h1>
</td>
</tr>

<tr valign="top">
<td style="background-color:#ffff99;width:100px;text-align:top;">
<b>Menu</b><br />
HTML<br />
CSS<br />
JavaScript
</td>
<td style="background-color:#EEEEEE;height:200px;width:400px;text-align:top;">
Content goes here</td>
</tr>

<tr>
<td colspan="2" style="background-color:#99bbbb;text-align:center;">
Copyright PHP中文網(wǎng)</td>
</tr>
</table>

</body>
</html>

上面的 HTML 代碼會(huì)產(chǎn)生以下結(jié)果:

%)$O5ZV1ZKT@N4]G1}8EP79.png

HTML 布局 - 有用的提示

提示:使用 CSS 最大的好處是,如果把 CSS 代碼存放到外部樣式表中,那么站點(diǎn)會(huì)更易于維護(hù)。通過(guò)編輯單一的文件,就可以改變所有頁(yè)面的布局。如需學(xué)習(xí)更多有關(guān) CSS 的知識(shí),請(qǐng)?jiān)L問(wèn)我們的 CSS 教程

提示:由于創(chuàng)建高級(jí)的布局非常耗時(shí),使用模板是一個(gè)快速的選項(xiàng)。通過(guò)搜索引擎可以找到很多免費(fèi)的網(wǎng)站模板(您可以使用這些預(yù)先構(gòu)建好的網(wǎng)站布局,并優(yōu)化它們)。

HTML 布局標(biāo)簽

標(biāo)簽描述
<div>定義文檔中的分區(qū)或節(jié)(division/section)。
<span>定義 span,用來(lái)組合文檔中的行內(nèi)元素。


Previous article: Next article: