参考文章:
http://www.kwstu.com/ArticleView/divcss_2013929173533658
1.css+div与table的区别(参考http://jingyan.baidu.com/article/3c48dd3474847ce10be3582f.html,http://wenwen.sogou.com/z/q221788124.htm?pos=5&ch=2013ww.tw.xgzs)
差别如下:当前情况下各有优劣。
类型 | 表现 | css | table |
趋势 | 趋势 | html2.0标准,趋势所在 | html1.0标准 |
浏览 | 网页打开速度 | 快(通常为table的1/2) | 慢 |
兼容性 | 各个浏览器兼容性 | 一般 | 好 |
兼容性 | 需要对各个浏览器单独开发 | 是 | 否 |
服务器 | 服务器压力 | 大规模时高(css属于外部引入需要多次链接) | 一次链接 |
代码 | 模式层面 | 支持网站的结构、表现、行为分离 | 不支持 |
代码 | 易用性 | 一般 | 易用 |
代码 | 所见即所得 | 否 | 是,DW环境下开发所见即所得 |
代码 | 可读性 | 一般 | 优 |
代码 | 开发速度 | 慢 | 快,DW下可以支持拖拽设置 |
代码 | 代码冗余 | 低 | 高 |
代码 | 代码修改(样式变更) | 好 | 差 |
seo | seo | 优 | 一般 |
2.css基础(开发时需要了解,参考http://www.cnblogs.com/polk6/archive/2013/07/25/3142187.html)
两个元素:内联元素、块级元素
两个流:文档流、浮动流
HTML页面的标准文档流(默认布局)是:从上到下,从左到右,遇块(块级元素)换行
3.设计步骤:先框架分块,后分块样式;
4.通过css+html创建网页的实际例子(
<!DOCTYPE html PU BLIC "-//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布局教程</title>
<style type="text/css">
#Container{
width:1000px;
margin:0 auto;/*设置整个容器在浏览器中水平居中*/
background:#CF3;
}
#Header{
height:80px;
background:#093;
}
#logo{
padding-left:50px;
padding-top:20px;
padding-bottom:50px;
}
#Content{
height:600px;
/*此处对容器设置了高度,一般不建议对容器设置高度,一般使用overflow:auto;属性设置容器根据内容自适应高度,如果不指定高度或不设置自适应高度,容器将默认为1个字符高度,容器下方的布局元素(footer)设置margin-top:属性将无效*/
margin-top:20px;/*此处讲解margin的用法,设置content与上面header元素之间的距离*/
background:#0FF;
}
#Content-Left{
height:400px;
width:200px;
margin:20px;/*设置元素跟其他元素的距离为20像素*/
float:left;/*设置浮动,实现多列效果,div+Css布局中很重要的*/
background:#90C;
}
#Content-Main{
height:400px;
width:720px;
margin:20px;/*设置元素跟其他元素的距离为20像素*/
float:left;/*设置浮动,实现多列效果,div+Css布局中很重要的*/
background:#90C;
}
/*注:Content-Left和Content-Main元素是Content元素的子元素,两个元素使用了float:left;设置成两列,这个两个元素的宽度和这个两个元素设置的padding、margin的和一定不能大于父层Content元素的宽度,否则设置列将失败*/
#Footer{
height:40px;
background:#90C;
margin-top:20px;
}
.Clear{
clear:both;
}
</style>
</head>
<body>
<div id="Container">
container
<div id="Header">
1.header
<div id="logo">1.1 logo:这里设置了padding属性介绍一下padding的用法,padding将设置文本与边框的距离。</div>
</div>
<div id="Content">
2.content
<div id="Content-Left">2.1 content-left:Content-Left</div>
<div id="Content-Main">2.2 content-main:Content-Main</div>
</div>
<div class="Clear">3.clear<!--如何你上面用到float,下面布局开始前最好清除一下。--></div>
<div id="Footer">4.Footer</div>
</div>
</body>
</html>