王洪林个人官网

标题: CSS初始化代码和html模板 [打印本页]

作者: admin    时间: 2015-6-19 16:54
标题: CSS初始化代码和html模板
为什么要初始化CSS?

CSS初始化是指重设浏览器的样式。不同的浏览器默认的样式可能不尽相同,所以开发时的第一件事可能就是如何把它们统一。如果没对CSS初始化往往会出现浏览器之间的页面差异。每次新开发网站或新网页时候通过初始化CSS样式的属性,为我们将用到的CSS或html标签更加方便准确,使得我们开发网页内容时更加方便简洁,同时减少CSS代码量,节约网页下载时间。

CSS初始化示例代码
  1. /* css reset www.admin10000.com */
  2. body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { margin:0; padding:0; }
  3. body { background:#fff; color:#555; font-size:14px; font-family: Verdana, Arial, Helvetica, sans-serif; }
  4. td,th,caption { font-size:14px; }
  5. h1, h2, h3, h4, h5, h6 { font-weight:normal; font-size:100%; }
  6. address, caption, cite, code, dfn, em, strong, th, var { font-style:normal; font-weight:normal;}
  7. a { color:#555; text-decoration:none; }
  8. a:hover { text-decoration:underline; }
  9. img { border:none; }
  10. ol,ul,li { list-style:none; }
  11. input, textarea, select, button { font:14px Verdana,Helvetica,Arial,sans-serif; }
  12. table { border-collapse:collapse; }
  13. html {overflow-y: scroll;}
  14. /* css common */
  15. .clearfix:after {content: "."; display: block; height:0; clear:both; visibility: hidden;}
  16. .clearfix { *zoom:1; }
复制代码

上面是admin10000.com网站使用的CSS重置代码,这段代码是我比较喜欢用的一种方式,虽然还不够完美但是常用的几乎已经都包括了。

各主流浏览器下的默认css样式ie6  |  ie7  |  ie8  |  ie9  | Firefox 3.6.3  |  Webkit (r57042)  | Opera 10.51

下面顺便给出admin10000.com网站 的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" lang="zh-cn">
  3. <head>
  4.   <title>网站标题 - Admin10000.com </title>
  5.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.         <meta http-equiv="Content-Language" content="zh-CN" />
  7.         <meta name="Author" content="网页作者" />
  8.         <meta name="Copyright" content="网站版权" />
  9.         <meta name="keywords" content="网站关键字" />
  10.         <meta name="description" content="网站描述" />
  11.         <link rel="Shortcut Icon" href="网站.ico图标路径" />
  12.         <link type="text/css" rel="stylesheet" href="CSS文件路径" />
  13.         <script type="text/javascript" src="JS文件路径"></script>
  14. </head>
  15. <body>
  16. </body>
  17. </html>
复制代码

本文链接地址:http://www.admin10000.com/document/16.html








欢迎光临 王洪林个人官网 (http://www.gamart.net/) Powered by Discuz! X3.2