2015.9.7

本次课程根据上次反应,对CSS样式进行二次讲解

1.框架的搭建

建立目标模板,简单分为container//总容器nav_container//导航栏banner//广告栏

Main_container//内容容器footer//底部栏

2.新建CSS文件

ID选择器设置背景颜色方便辨认框体

#container{width=100%;background-color:#C03;}

#nav_container{width:800px;height:50px;background-color:#09F;margin:0auto;}//设置导航栏的长宽及背景色margin属性设为0auto为居中显示

#banner{width:800px;height:100px;background-color:#F90;margin:0auto;}//设置广告栏的属性

#Main_container{width:800px;background-color:#FC0;margin:0auto;}//设置内容容器的属性其中的height属性为空(清除浮动)类似于贴吧回帖模式时根据帖子内容框体变高

#footer{width:800px;height:50px;background-color:#FF0;margin:0auto;}/设置底部内容

3.将CSS文件与HTML文件链接

<linkhref="css/style.css"rel="stylesheet"type="text/css"/>//重要的参数rel

4.对HTML页面进行调整划分

<divid="container">

<divid="nav_container">

<divid="nav_left"></div>

<divid="nav_right">

<ul>

<li><ahref="#">首页</a></li>

<li><ahref="#">新闻</a></li>

<li><ahref="#">介绍</a></li>

</ul>

</div>

</div>

<divid="banner"></div>

<divid="Main_container">

<divid="Main_left">

<divid="Main_left_top"></div>

<divid="Main_left_bottom"></div>

</div>

<divid="Main_right"></div>

<divstyle="clear:both;">

</div>

<divid="footer">

</div>

</div>

5.写入CSS样式

#container{width=100%;background-color:#C03;}

#nav_container{width:800px;height:50px;background-color:#09F;margin:0auto;}

#nav_left{width:150px;height:50px;background-color:#FC0;float:left;}

#nav_right{width:650px;height:50px;background-color:#99C;float:right;}

#nav_rightul{margin:0;padding:0px;}

#nav_rightulli{float:left;list-style-type:none;text-align:center;}

#nav_rightullia{display:block;height:50px;width:50px;text-decoration:none;}/*display使用内联元素变成块状元素text-decorationw为·

#nav_rightullia:hover{background-color:#999;}//hover是将导航栏设置为滑动显示

#banner{width:800px;height:100px;background-color:#F90;margin:0auto;}

#Main_container{width:800px;background-color:#FC0;margin:0auto;}

#Main_left{width:400px;height:400px;background-color:#66C;float:left;}/*floatleftright*/

#Main_left_top{400px;height:200px;background-color:#63F;}

#Main_left_bottom{width:400px;height:200px;background-color:#30F;}

#Main_right{width:400px;height:400px;background-color:#96C;float:right;}/*浮动之后清除浮动*///float浮动使用完毕后进行清除,也可以在所有的使用结束后一并清除

#footer{width:800px;height:50px;background-color:#FF0;margin:0auto;}

5.至此网站的基本框架搭建完成