返回首页
当前位置: 主页 > DIV+CSS 教程 >

整理常用的DIV CSS网站布局的基本框架结构

时间:2010-01-01 10:43来源:网络 作者:秩名 点击:
css中国,今天整理的自己用的div+css基本框架结构,这次不再是搭建基本的框架,更结节的块结构也做出来了,如果符合这种结构的可以直接拿来使用。在IE和FF下测试没变形,但没测试

css中国,今天整理的自己用的div+css基本框架结构,这次不再是搭建基本的框架,更结节的块结构也做出来了,如果符合这种结构的可以直接拿来使用。在IE和FF下测试没变形,但没测试W3C认证,估计还通不过。呵呵

HTML页面结构代码:

 

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head> 
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  5. <title>常用的DIV+CSS网站布局的基本框架结构</title> 
  6. <link href="/css/layout.css" rel="stylesheet" type="text/css" /> 
  7. </head> 
  8.  
  9. <body> 
  10. <div id="container"> 
  11.     <div id="header"> 
  12.         <h1>头部</h1> 
  13.     </div> 
  14.   <div class="clearfloat"></div> 
  15.     <div id="nav"> 
  16.       <ul> 
  17.         <li><a href="#">导航一</a></li> 
  18.         <li><a href="#">导航二</a></li> 
  19.         <li><a href="#">导航三</a></li> 
  20.         <li><a href="#">导航四</a></li> 
  21.         <li><a href="#">导航五</a></li> 
  22.       </ul> 
  23.     </div> 
  24. <div id="mainContent"> 
  25.     <div id="side"> 
  26.           <div class="sidebox"> 
  27.             <h4>块标题</h4> 
  28.             <ul>块内容</ul> 
  29.           </div> 
  30.         </div> 
  31.         <div id="main"> 
  32.           <div class="mainbox"> 
  33.             <h2>块标题</h2> 
  34.             <ul>块内容</ul> 
  35.           </div> 
  36.         </div> 
  37.     </div> 
  38.     <div class="clearfloat"></div> 
  39.     <div id="footer"> 
  40.     底部  
  41.     </div> 
  42. </div> 
  43. </body> 
  44. </html> 
  45.  

CSS样式表layout.css代码:

  1. @charset "utf-8";  
  2. /* CSS Document */ 
  3.    
  4.  
  5. @import url("/css/global.css");  
  6.  
  7. /*body*/ 
  8. #container {margin:0 autowidth:950px;}  
  9. a { color:#333;}  
  10.  
  11. /*header*/ 
  12. #header { height:50pxbackground:#ff911a;}  
  13. #header h1 { padding:10px 20px;}  
  14. #nav { background:#FF6600height:24pxmargin-bottom:6px;}  
  15. #nav ul li { float:left;}  
  16. #nav ul li a { display:blockpadding:4px 10px 2px 10pxcolor:#ffftext-decoration:none;}  
  17. #nav ul li a:hover { text-decoration:underline;}  
  18.  
  19. /*main*/ 
  20. #mainContent { overflow:auto; zoom:1margin-bottom:6px;}  
  21. #side { width:200pxfloat:left;}  
  22. .sidebox { border:1px solid #ed6400margin-bottom:6px;}  
  23. .sidebox h4 { background:#ff911apadding:2px 6pxborder-bottom:1px solid #ed6400color:#fff;}  
  24. .sidebox ul { padding:4px 6px;}  
  25. #mainwidth:742pxfloat:right;}  
  26. .mainbox { border:1px solid #ed6400margin-bottom:6px;}  
  27. .mainbox h2 { background:#ff911apadding:2px 6pxborder-bottom:1px solid #ed6400color:#fff;}  
  28. .mainbox ul { padding:4px 6px;}  
  29.  
  30. /*footer*/ 
  31. #footer { border-top:3px solid #cccheight:50pxtext-align:centerpadding:6px;}  
  32.  

被包含的CSS样式表global.css代码(把用于全局的样式单独放在一个样式表中,避免重复,方便调用):

  1. @charset "utf-8";  
  2. body { margin:0 autofont-size:12pxfont-family:Verdanaline-height:150%;}  
  3. ul,dl,h1,h2,h3,h4,h5,h6,form { padding:0margin:0;}  
  4. h1 { font-size:18px;}  
  5. h2 { font-size:14px;}  
  6. h3 { font-size:14pxfont-weight:normal;}  
  7. h4 { font-size:12px;}  
  8. h5 { font-size:12pxfont-weight:normal;}  
  9. ul { list-style:none;}  
  10. img { border:0px;}  
  11.  
  12. .clearfloat {clear:both;height:0;font-size1px;line-height0px;}   

 

(责任编辑:admin)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名:密码: 验证码:点击我更换图片
推荐内容