DIV+CSS通用樣式布局實(shí)例代碼
發(fā)布時(shí)間:2012-02-20 16:14:54 作者:佚名
我要評論

對于剛開始接觸DIV+CSS的同學(xué)來說,記住那些對象屬性以及對應(yīng)的值就很困難了,更何況來完成頁面的布局了
一下是一個(gè)非常簡單易懂的通用樣式布局,希望對于剛開始接觸DIV+CSS的同學(xué)有幫助。先看效果圖:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>DIV+CSS practice</title>
<link href="css/common.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<!-- 頭部 -->
<div id="head">
</div>
<!--END 頭部 -->
<!-- 主容器 -->
<div id="container">
<!-- 左側(cè)主顯區(qū) -->
<div id="content">
</div>
<!-- END 左側(cè)主顯區(qū) -->
<!-- 右側(cè)邊欄 -->
<div id="side">
</div>
<!-- END 右側(cè)邊欄 -->
</div>
<!-- END 主容器 -->
<div class="clear"></div>
<!-- 底部 -->
<div id="foot">
</div>
<!-- END 底部 -->
</body>
</html>
common.css樣式文件:
*{
margin:0;
padding:0;
}
body{
background-color:gray;
}
.clear{
clear:both;
}
/*head*/
#head{
background-color:blue;
height:150px;
}
/*container*/
#container{
background-color:red;
width:960px;
height:800px;
margin:20px auto;
}
/*content*/
#content{
background-color:yellow;
float:left;
width:685px;
height:100%;
}
/*side*/
#side{
background-color:green;
float:right;
width:255px;
height:100%;
}
/*foot*/
#foot{
background-color:white;
height:150px;
width:960px;
margin:20px auto;
}
大致布局很簡單了,首先要有這個(gè)大局觀,然后再完善其中的細(xì)節(jié),學(xué)習(xí)PHP或者其他語言同樣如此,首先要有一個(gè)思想,知道每一步做什么,怎么做,這樣才能把知識靈活運(yùn)用。
我們可以看出通常的頁面布局有以下幾個(gè)部分:頭部、內(nèi)容、底部,其中內(nèi)容有左側(cè)主顯區(qū)和右側(cè)邊欄。下面貼出代碼:
復(fù)制代碼
代碼如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>DIV+CSS practice</title>
<link href="css/common.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<!-- 頭部 -->
<div id="head">
</div>
<!--END 頭部 -->
<!-- 主容器 -->
<div id="container">
<!-- 左側(cè)主顯區(qū) -->
<div id="content">
</div>
<!-- END 左側(cè)主顯區(qū) -->
<!-- 右側(cè)邊欄 -->
<div id="side">
</div>
<!-- END 右側(cè)邊欄 -->
</div>
<!-- END 主容器 -->
<div class="clear"></div>
<!-- 底部 -->
<div id="foot">
</div>
<!-- END 底部 -->
</body>
</html>
common.css樣式文件:
*{
margin:0;
padding:0;
}
body{
background-color:gray;
}
.clear{
clear:both;
}
/*head*/
#head{
background-color:blue;
height:150px;
}
/*container*/
#container{
background-color:red;
width:960px;
height:800px;
margin:20px auto;
}
/*content*/
#content{
background-color:yellow;
float:left;
width:685px;
height:100%;
}
/*side*/
#side{
background-color:green;
float:right;
width:255px;
height:100%;
}
/*foot*/
#foot{
background-color:white;
height:150px;
width:960px;
margin:20px auto;
}
大致布局很簡單了,首先要有這個(gè)大局觀,然后再完善其中的細(xì)節(jié),學(xué)習(xí)PHP或者其他語言同樣如此,首先要有一個(gè)思想,知道每一步做什么,怎么做,這樣才能把知識靈活運(yùn)用。
相關(guān)文章
網(wǎng)頁布局中CSS樣式無效的十個(gè)重要原因詳解
這篇文章主要介紹了網(wǎng)頁布局中CSS樣式無效的十個(gè)重要原因,標(biāo)簽或alt屬性以及不良的書寫規(guī)范都有可能引起樣式無效,廣大讀者可根據(jù)自身遇到的情況進(jìn)行分析對照,希望對大家2017-08-10HTML基礎(chǔ)知識——css樣式表,樣式屬性,格式與布局詳解
下面小編就為大家?guī)硪黄狧TML基礎(chǔ)知識——css樣式表,樣式屬性,格式與布局詳解。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-07-11- 下面小編就為大家?guī)硪黄狢SS樣式表與格式布局詳解。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-29
- 對于簡單的Web站點(diǎn),可以只使用一個(gè)CSS文件。對于大型的復(fù)雜站點(diǎn),對樣式表進(jìn)行分割以便簡化維護(hù)是一種好做法。2011-10-07
- 這篇文章主要介紹了常用css樣式(布局)及CSS常用樣式匯編的相關(guān)知識,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-10-28