陈力:传智播客古代 珍宝币 泡泡龙游戏开发第十四讲:DIV+CSS实例
摘要:通过前节《第十三讲:盒子的定位实例》学习了网站建设中的DIV+CSS中盒子模型,介绍利用CSS进行盒子的定位实例,介绍了4种不同类型的定位static、relative、absolute、fixed定位机制。本节对DIV+CSS实例综合应用实例进行介绍。
什么是DIV+SCC的盒子模型?
在网站建设中关于内容(content)、填充(padding)、边框(border)、边界(margin),CSS盒子模式这些属性。一个盒子模型由内至外由content(内容),padding(填充),border(边框),margin(边界)四部分组成,如图所示。[了解更多]深入理解盒子模型
一、实例效果图
二、html程序设计代码
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="sohu.css"/>
</head>
<body>
<!--top部分-->
<div class="top">
<span class="login">登录表单</span>
<span class="setindex">设置首页面</span>
<span class="myfref">超链接</span>
</div>
<!--logo部分代码-->
<DIv class="logo">
<img src="logo.png"/>
</div>
<!--导航-->
<div class="nav1">
</div>
<!--广告-->
<Div class="adAll">
<div class="adstu">
招生广告
</div>
<div class="adSport">
运动广告
</div>
<div class="fdc">
房地产
</div>
<div class="adimg">
<img src="ad2.png"/>
图片广告
</div>
</div>
<body>
</html>
三、CSS程序设计代码(sohu.css)
body{
margin:0 auto;
/*border:1px;边框*/
width:950px;
height:800px;
font-size:12px;
}
.top{
width:950px;
background:silver;
height:24px;
}
.login{
width:350px;
height:22px;
background:pink;
float:left;
}
.setindex{
width:85px;
height:20px;
background:green;
float:left;
margin-left:100px;
}
.myfref{
float:right;
margin-right:5px;
margin-top:3px;
}
.logo{
width:138px;
height:56px;
background:silver;
float:left;
margin-top:3px;
}
.logo img{
width:138px;
height:56px;
}
.nav1{
width:800px;
height:56px;
background:#7BF773;
float:left;
margin-top:3px;
margin-left:10px;
}
/*广告*/
.adAll{
width:950px;
height:211px;
/*background:silver;*/
margin-top:3px;
border:1px solid silver;
float:left;
}
/*招生广告*/
.adstu{
width:126px;
height:195px;
background:#7BF773;
float:left;
margin:5px 0 0 5px;
}
.adSport{
width:451px;
height:195px;
background:#7BF773;
float:left;
margin:5px 0 0 15px;
}
.fdc{
width:151px;
height:195px;
background:#7BF773;
float:left;
margin:5px 0 0 15px;
}
.adimg{
width:180px;
height:211px;
/*background:pink;*/
float:right;
text-align:center;/*图片或文字居中*/
border-left:1px solid silver;
}
.adimg img{
margin-top:10px;
}
在DIV+CSS网页布局方式中元素定位是比较晦涩的方面,即使有经验的CSS开发人员也会遇到一些问题。本文“《陈力:传智播客古代 珍宝币 泡泡龙游戏开发第十四讲:DIV+CSS实例》第十三讲:DIV+CSS实例综合应用实例进行介绍”的分析,使DIV+CSS网页布局中的定位技术更容易被理解和应用。
【推荐阅读】
陈力:传智播客古代 珍宝币 泡泡龙游戏开发第十四讲:DIV+CSS实例