div結(jié)合css布局bbs首頁(yè)(div+css布局入門)
更新時(shí)間:2008年11月01日 23:51:39 作者:
最近趁離職,我在做一個(gè)論壇系統(tǒng),練練手,需要一個(gè)論壇首頁(yè)的html頁(yè)面,深知自己美工極差,心里很苦啊。于是買了本div+css網(wǎng)站布局的書,沒想到講得還不錯(cuò),感覺長(zhǎng)進(jìn)很快,于是磨拳擦掌非要自己寫一個(gè)不可,高手末笑。代碼伺候。
我把論壇首頁(yè)分為header區(qū),信息區(qū),內(nèi)容區(qū),頁(yè)腳區(qū)。首先用一大div把這些包含進(jìn)來,主要是考慮到頁(yè)面整體調(diào)節(jié)方便,比如要調(diào)成寬屏的或者是窄屏的,只要設(shè)置一下這個(gè)大div就可以了。
先把代碼貼出來,供朋友們調(diào)試使用。
css:
/* CSS Document */
body{
background-color:#F5F5F5;
margin:0;
padding:0;
font-family : "Lucida Grande", Verdana, Lucida, Arial, Helvetica, ,sans-serif;
font-size:12px;
}
.pagehoder{
width:100%;
margin:auto;
background-color:#2662DF;
border-left:2px solid #7197D7;
border-rigth:2px solid #7197D7;
border-bottom:2px solid #7197D7;
}
.header{
border-top:2px solid #7197D7;
height:60px;
background-color: #B1C3D9;
}
.logo{
background:url(../images/logo.png) no-repeat ;
width:200px;
height:60px;
float:left;
}
.img{
background:url(../images/images1.jpg) repeat-x ;
height:60px;
}
.navigate {
padding-left:20px;
background-color:#F3F8FE;
height:10px;
}
.navigate li{
float:left;
}
.navigate li a{
margin-left:2px;
padding-top:3px;
padding-bottom:3px;
text-align:center;
display:block;
text-decoration:none;
width:70px;
height:10px;
background-color:#ececec;
}
.navigate li a:hover{
color:#ffffff;
background-color:#bbbbbb;
}
.notice{
background-color:#ffffff;
height:20px;
}
.content{
background-color:#0000FF;
height:400px;
}
.contentHead{
text-align:center;
padding-top:5px;
padding-bottom:0px;
height:20px;
background-color:#71A3CC;
}
.f1{
width:60%;
float:left;
background-color:#71A3CC;
}
.f2{
width:12%;
float:left;
background-color:#71A3CC;
}
.f3{
width:12%;
float:left;
background-color:#71A3CC;
}
.f4{
width:15%;
background-color:#71A3CC;
}
.typeHolder{
width:100%;
background-color:#D9DBE4;
}
.type{
width:60%;
float:left;
}
.boardHolder{
text-align:center;
width:100%;
background-color:#FFFFFF;
}
.boardName{
width:60%;
float:left;
}
.subject{
width:12%;
float:left;
background-color:#F7F7F8;
}
.article{
width:12%;
float:left;
background-color:#F7F7F8;
}
.last{
width:15%;
background-color:#F7F7F8;
}
.msg{
background-color:#FAFAFA;
height:60px;
}
.footer{
background-color:#99CC33;
height:20px;
text-align:center;
}
.
html:
<!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=gb2312" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<title>sclBBS首頁(yè)</title>
</head>
<body>
<div class="pagehoder">
<div class="header">
<div class="logo">
</div>
<div class="img"></div>
</div>
<div class="navigate">
<li> <a href="#">首頁(yè)</a></li>
<li> <a href="#">搜索</a></li>
<li> <a href="#">會(huì)員列表</a></li>
<li> <a href="#">熱門主題</a></li>
<li> <a href="#">最新主題</a></li>
</div>
<div class="notice">
<marquee scrollAmount="2" width="100%">
歡迎光臨sclBBS。
</marquee>
</div>
<div class="content">
<div class="contentHead">
<div class="f1">版面</div>
<div class="f2">主題</div>
<div class="f3">文章</div>
<div class="f4">最后發(fā)表</div>
</div>
<div class="typeHolder">
<div class="type">開源項(xiàng)目</div>
<div class="place"></div>
</div>
<div class="boardHolder">
<div class="boardName">JForum論壇</div>
<div class="subject">23</div>
<div class="article">23</div>
<div class="last">23</div>
</div>
<div class="typeHolder">
<div class="type">開源項(xiàng)目1</div>
<div class="place"></div>
</div>
<div class="boardHolder">
<div class="boardName">JForum論壇1</div>
<div class="subject">23</div>
<div class="article">23</div>
<div class="last">23</div>
</div>
<div class="typeHolder">
<div class="type">開源項(xiàng)目2</div>
<div class="place"></div>
</div>
<div class="boardHolder">
<div class="boardName">JForum論壇2</div>
<div class="subject">23</div>
<div class="article">23</div>
<div class="last">23</div>
</div>
<div class="typeHolder">
<div class="type">開源項(xiàng)目3</div>
<div class="place"></div>
</div>
<div class="boardHolder">
<div class="boardName">JForum論壇3</div>
<div class="subject">23</div>
<div class="article">23</div>
<div class="last">23</div>
</div>
</div>
<div class="msg">
<div class="typeHolder">
<div class="type">看誰在線上</div>
<div class="place"></div>
</div>
<div class="boardHolder">
目前總共發(fā)表了 2,806 篇文章
目前總共有 4,186 位注冊(cè)會(huì)員
最新注冊(cè)的會(huì)員: mxjccut
目前總共有 80 位用戶在線 :: 1 位會(huì)員, 79 位訪客 [ 系統(tǒng)管理員 ] [ 版主 ]
最高在線人數(shù) 2,712 人 [ 記錄時(shí)間 :: 2007-08-13 16:12:34 ]
目前在線注冊(cè)會(huì)員: Admin
</div>
</div>
<div class="footer">
Powered by sclBBS author:sclsch@188.com
</div>
</div>
</body>
</html>
圖片不能上傳,沒辦法了,不影響學(xué)習(xí)。
這是我設(shè)計(jì)的第一個(gè)布局,從中了解了,div是塊狀的,默認(rèn)是占整行的,如果想設(shè)計(jì)成兩列或多列,可以用float屬性,它可以向左(float:left)浮動(dòng),這時(shí),如果下面的div大小可以放下的話,就會(huì)浮動(dòng)到上面一行,這樣就形成了兩列的布局,
多列以此類推。理解了基本的,以后就可以向細(xì)的方向?qū)W習(xí)了。希望給像我一樣的初學(xué)美工的朋友點(diǎn)幫助,做開發(fā)的了解美工也很重要,藝多不壓身嘛。
先把代碼貼出來,供朋友們調(diào)試使用。
css:
復(fù)制代碼 代碼如下:
/* CSS Document */
body{
background-color:#F5F5F5;
margin:0;
padding:0;
font-family : "Lucida Grande", Verdana, Lucida, Arial, Helvetica, ,sans-serif;
font-size:12px;
}
.pagehoder{
width:100%;
margin:auto;
background-color:#2662DF;
border-left:2px solid #7197D7;
border-rigth:2px solid #7197D7;
border-bottom:2px solid #7197D7;
}
.header{
border-top:2px solid #7197D7;
height:60px;
background-color: #B1C3D9;
}
.logo{
background:url(../images/logo.png) no-repeat ;
width:200px;
height:60px;
float:left;
}
.img{
background:url(../images/images1.jpg) repeat-x ;
height:60px;
}
.navigate {
padding-left:20px;
background-color:#F3F8FE;
height:10px;
}
.navigate li{
float:left;
}
.navigate li a{
margin-left:2px;
padding-top:3px;
padding-bottom:3px;
text-align:center;
display:block;
text-decoration:none;
width:70px;
height:10px;
background-color:#ececec;
}
.navigate li a:hover{
color:#ffffff;
background-color:#bbbbbb;
}
.notice{
background-color:#ffffff;
height:20px;
}
.content{
background-color:#0000FF;
height:400px;
}
.contentHead{
text-align:center;
padding-top:5px;
padding-bottom:0px;
height:20px;
background-color:#71A3CC;
}
.f1{
width:60%;
float:left;
background-color:#71A3CC;
}
.f2{
width:12%;
float:left;
background-color:#71A3CC;
}
.f3{
width:12%;
float:left;
background-color:#71A3CC;
}
.f4{
width:15%;
background-color:#71A3CC;
}
.typeHolder{
width:100%;
background-color:#D9DBE4;
}
.type{
width:60%;
float:left;
}
.boardHolder{
text-align:center;
width:100%;
background-color:#FFFFFF;
}
.boardName{
width:60%;
float:left;
}
.subject{
width:12%;
float:left;
background-color:#F7F7F8;
}
.article{
width:12%;
float:left;
background-color:#F7F7F8;
}
.last{
width:15%;
background-color:#F7F7F8;
}
.msg{
background-color:#FAFAFA;
height:60px;
}
.footer{
background-color:#99CC33;
height:20px;
text-align:center;
}
html:
復(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=gb2312" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<title>sclBBS首頁(yè)</title>
</head>
<body>
<div class="pagehoder">
<div class="header">
<div class="logo">
</div>
<div class="img"></div>
</div>
<div class="navigate">
<li> <a href="#">首頁(yè)</a></li>
<li> <a href="#">搜索</a></li>
<li> <a href="#">會(huì)員列表</a></li>
<li> <a href="#">熱門主題</a></li>
<li> <a href="#">最新主題</a></li>
</div>
<div class="notice">
<marquee scrollAmount="2" width="100%">
歡迎光臨sclBBS。
</marquee>
</div>
<div class="content">
<div class="contentHead">
<div class="f1">版面</div>
<div class="f2">主題</div>
<div class="f3">文章</div>
<div class="f4">最后發(fā)表</div>
</div>
<div class="typeHolder">
<div class="type">開源項(xiàng)目</div>
<div class="place"></div>
</div>
<div class="boardHolder">
<div class="boardName">JForum論壇</div>
<div class="subject">23</div>
<div class="article">23</div>
<div class="last">23</div>
</div>
<div class="typeHolder">
<div class="type">開源項(xiàng)目1</div>
<div class="place"></div>
</div>
<div class="boardHolder">
<div class="boardName">JForum論壇1</div>
<div class="subject">23</div>
<div class="article">23</div>
<div class="last">23</div>
</div>
<div class="typeHolder">
<div class="type">開源項(xiàng)目2</div>
<div class="place"></div>
</div>
<div class="boardHolder">
<div class="boardName">JForum論壇2</div>
<div class="subject">23</div>
<div class="article">23</div>
<div class="last">23</div>
</div>
<div class="typeHolder">
<div class="type">開源項(xiàng)目3</div>
<div class="place"></div>
</div>
<div class="boardHolder">
<div class="boardName">JForum論壇3</div>
<div class="subject">23</div>
<div class="article">23</div>
<div class="last">23</div>
</div>
</div>
<div class="msg">
<div class="typeHolder">
<div class="type">看誰在線上</div>
<div class="place"></div>
</div>
<div class="boardHolder">
目前總共發(fā)表了 2,806 篇文章
目前總共有 4,186 位注冊(cè)會(huì)員
最新注冊(cè)的會(huì)員: mxjccut
目前總共有 80 位用戶在線 :: 1 位會(huì)員, 79 位訪客 [ 系統(tǒng)管理員 ] [ 版主 ]
最高在線人數(shù) 2,712 人 [ 記錄時(shí)間 :: 2007-08-13 16:12:34 ]
目前在線注冊(cè)會(huì)員: Admin
</div>
</div>
<div class="footer">
Powered by sclBBS author:sclsch@188.com
</div>
</div>
</body>
</html>
圖片不能上傳,沒辦法了,不影響學(xué)習(xí)。
這是我設(shè)計(jì)的第一個(gè)布局,從中了解了,div是塊狀的,默認(rèn)是占整行的,如果想設(shè)計(jì)成兩列或多列,可以用float屬性,它可以向左(float:left)浮動(dòng),這時(shí),如果下面的div大小可以放下的話,就會(huì)浮動(dòng)到上面一行,這樣就形成了兩列的布局,
多列以此類推。理解了基本的,以后就可以向細(xì)的方向?qū)W習(xí)了。希望給像我一樣的初學(xué)美工的朋友點(diǎn)幫助,做開發(fā)的了解美工也很重要,藝多不壓身嘛。
相關(guān)文章
讓超出DIV寬度范圍的文字自動(dòng)顯示省略號(hào)...
關(guān)鍵是:text-overflow: ellipsis;2008-10-10學(xué)習(xí)WEB標(biāo)準(zhǔn)總結(jié)的一些CSS/XHTML知識(shí)小結(jié)
制作網(wǎng)頁(yè)過程中,總會(huì)遇到一些CSS/XHTML的各種問題,下面大體的總結(jié)了下2008-09-09