当前位置: 移动技术网 > IT编程>网页制作>CSS > div结合css布局bbs首页(div+css布局入门)

div结合css布局bbs首页(div+css布局入门)

2017年12月08日  | 移动技术网IT编程  | 我要评论

中央指的大老虎是谁,吉林移动网上营业厅,英伦宝贝童话屋

我把论坛首页分为header区,信息区,内容区,页脚区。首先用一大div把这些包含进来,主要是考虑到页面整体调节方便,比如要调成宽屏的或者是窄屏的,只要设置一下这个大div就可以了。
先把代码贴出来,供朋友们调试使用。
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首页</title>
</head>

<body>
<div class="pagehoder">
<div class="header">
<div class="logo">
</div>
<div class="img"></div>
</div>
<div class="navigate">
<li> <a href="#">首页</a></li>
<li> <a href="#">搜索</a></li>
<li> <a href="#">会员列表</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">最后发表</div>
</div>
<div class="typeholder">
<div class="type">开源项目</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">开源项目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">开源项目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">开源项目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">

目前总共发表了 2,806 篇文章
目前总共有 4,186 位注册会员
最新注册的会员: mxjccut
目前总共有 80 位用户在线 :: 1 位会员, 79 位访客 [ 系统管理员 ] [ 版主 ]
最高在线人数 2,712 人 [ 记录时间 :: 2007-08-13 16:12:34 ]
目前在线注册会员: admin

</div>


</div>
<div class="footer">
powered by sclbbs author:sclsch@188.com
</div>
</div>
</body>
</html>


图片不能上传,没办法了,不影响学习。
这是我设计的第一个布局,从中了解了,div是块状的,默认是占整行的,如果想设计成两列或多列,可以用float属性,它可以向左(float:left)浮动,这时,如果下面的div大小可以放下的话,就会浮动到上面一行,这样就形成了两列的布局,
多列以此类推。理解了基本的,以后就可以向细的方向学习了。希望给像我一样的初学美工的朋友点帮助,做开发的了解美工也很重要,艺多不压身嘛。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网