立即注册 找回密码

QQ登录

只需一步,快速开始

查看: 3237|回复: 0

不同浏览器对对不同的元素设置 通过对css的控制实现初始化

[复制链接]
发表于 2014-10-7 10:29:16 | 显示全部楼层 |阅读模式
道勤网-数据www.daoqin.net

亲注册登录道勤网-可以查看更多帖子内容哦!(包涵精彩图片、文字详情等)请您及时注册登录-www.daoqin.net

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 网页学习者 于 2014-10-7 10:36 编辑

不同浏览器对对不同的元素设置 通过对css的控制实现初始化

相同的元素,如li,在不同的浏览器下,显示的效果会稍有不同!</br>
                    是因为各个浏览器对元素的margin\border\font-size等略有不同!</br>
                    杜绝这样的情况,我们可以通过css的设置,让他们在不同的浏览器中的显示都是一样就可以!<br/>
                    那么,这样浏览器的显示就一致了!减少了不兼容的情况发生!<br/>
                    这个过程,叫css初始化!<br/>


初始化代码如下:
  1. /*css reset code */

  2. /****  文字大小初始化,使1em=10px *****/
  3. body {
  4. font-size:62.5%;
  5. } /* for IE/Win */
  6. html>body {
  7. font-size:10px;
  8. } /* for everything else */

  9. /*字体边框等初始化*/
  10. body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
  11. padding: 0;
  12. margin: 0;
  13. }
  14. table {
  15. border-collapse: collapse;
  16. border-spacing: 0;
  17. }
  18. fieldset,img {
  19. border: 0;
  20. }
  21. img {
  22. display:block;
  23. }
  24. address,caption,cite,code,dfn,th,var {
  25. font-weight: normal;
  26. font-style: normal;
  27. }
  28. ol,ul {
  29. list-style: none;
  30. }
  31. caption,th {
  32. text-align: left;
  33. }
  34. h1,h2,h3,h4,h5,h6 {
  35. font-weight: normal;
  36. font-size: 100%;
  37. }
  38. q:before,q:after {
  39. content:'';
  40. }
  41. abbr,acronym { border: 0;
  42. }

  43. a {
  44. text-decoration:none;
  45. }
复制代码
其他初始化代码

  1. 腾讯QQ官网(http://www.qq.com[/url])样式初始化


  2. body,ol,ul,h1,h2,h3,h4,h5,h6,p,th,td,dl,dd,form,fieldset,legend,input,textarea,select{margin:0;padding:0}
  3. body{font:12px"宋体","Arial Narrow",HELVETICA;background:#fff;-webkit-text-size-adjust:100%;}
  4. a{color:#2d374b;text-decoration:none}
  5. a:hover{color:#cd0200;text-decoration:underline}
  6. em{font-style:normal}
  7. li{list-style:none}
  8. img{border:0;vertical-align:middle}
  9. table{border-collapse:collapse;border-spacing:0}
  10. p{word-wrap:break-word}
  11. 新浪官网(http://www.sina.com.cn/)样式初始化


  12. body,ul,ol,li,p,h1,h2,h3,h4,h5,h6,form,fieldset,table,td,img,div{margin:0;padding:0;border:0;}
  13. body{background:#fff;color:#333;font-size:12px; margin-top:5px;font-family:"SimSun","宋体","Arial Narrow";}

  14. ul,ol{list-style-type:none;}
  15. select,input,img,select{vertical-align:middle;}

  16. a{text-decoration:none;}
  17. a:link{color:#009;}
  18. a:visited{color:#800080;}
  19. a:hover,a:active,a:focus{color:#c00;text-decoration:underline;}
  20. 淘宝官网(http://www.taobao.com/)样式初始化(淘宝的样式是经过压缩的,我自己拷下来格式化过的)


  21. body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td { margin:0; padding:0; }
  22. body, button, input, select, textarea { font:12px/1.5tahoma, arial, \5b8b\4f53; }
  23. h1, h2, h3, h4, h5, h6{ font-size:100%; }
  24. address, cite, dfn, em, var { font-style:normal; }
  25. code, kbd, pre, samp { font-family:couriernew, courier, monospace; }
  26. small{ font-size:12px; }
  27. ul, ol { list-style:none; }
  28. a { text-decoration:none; }
  29. a:hover { text-decoration:underline; }
  30. sup { vertical-align:text-top; }
  31. sub{ vertical-align:text-bottom; }
  32. legend { color:#000; }
  33. fieldset, img { border:0; }
  34. button, input, select, textarea { font-size:100%; }
  35. table { border-collapse:collapse; border-spacing:0; }
  36. 网易官网([url]http://www.163.com/)样式初始化


  37. html {overflow-y:scroll;}
  38. body {margin:0; padding:29px00; font:12px"\5B8B\4F53",sans-serif;background:#ffffff;}
  39. div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,blockquote,p{padding:0; margin:0;}
  40. table,td,tr,th{font-size:12px;}
  41. li{list-style-type:none;}
  42. img{vertical-align:top;border:0;}
  43. ol,ul {list-style:none;}
  44. h1,h2,h3,h4,h5,h6{font-size:12px; font-weight:normal;}
  45. address,cite,code,em,th {font-weight:normal; font-style:normal;}
复制代码

下面是我们写的一个,可以交流哦哈,效果如下
006.jpg
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
  3. <head>
  4. <title>新建网页</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="description" content="道勤教育 http://www.daoqin.net" />
  7. <style>
  8.         /*css reset code */

  9. /****  文字大小初始化,使1em=10px *****/
  10. body {
  11. font-size:62.5%;
  12. } /* for IE/Win */
  13. html>body {
  14. font-size:10px;
  15. } /* for everything else */

  16. /*字体边框等初始化*/
  17. body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
  18. padding: 0;
  19. margin: 0;
  20. }
  21. table {
  22. border-collapse: collapse;
  23. border-spacing: 0;
  24. }
  25. fieldset,img {
  26. border: 0;
  27. }
  28. img {
  29. display:block;
  30. }
  31. address,caption,cite,code,dfn,th,var {
  32. font-weight: normal;
  33. font-style: normal;
  34. }
  35. ol,ul {
  36. list-style: none;
  37. }
  38. caption,th {
  39. text-align: left;
  40. }
  41. h1,h2,h3,h4,h5,h6 {
  42. font-weight: normal;
  43. font-size: 100%;
  44. }
  45. q:before,q:after {
  46. content:'';
  47. }
  48. abbr,acronym { border: 0;
  49. }

  50. a {
  51. text-decoration:none;
  52. }
  53. </style>
  54. </head>
  55.     <body>
  56.             <div>
  57.                     相同的元素,如li,在不同的浏览器下,显示的效果会稍有不同!</br>
  58.                     是因为各个浏览器对元素的margin\border\font-size等略有不同!</br>
  59.                     杜绝这样的情况,我们可以通过css的设置,让他们在不同的浏览器中的显示都是一样就可以!<br/>
  60.                     那么,这样浏览器的显示就一致了!减少了不兼容的情况发生!<br/>
  61.                     这个过程,叫css初始化!<br/>
  62.                     <ul>
  63.                             <li>a</li>
  64.                             <li>b</li>
  65.                             <li>c</li>
  66.                             <li>d</li>



  67.                     </ul>


  68.             </div>
  69.     </body>
  70. </html>
复制代码


道勤主机提供365天*24小时全年全天无休、实时在线、零等待的售后技术支持。竭力为您免费处理您在使用道勤主机过程中所遇到的一切问题! 如果您是道勤主机用户,那么您可以通过QQ【792472177】、售后QQ【59133755】、旺旺【诠释意念】、微信:q792472177免费电话、后台提交工单这些方式联系道勤主机客服! 如果您不是我们的客户也没问题,点击页面最右边的企业QQ在线咨询图标联系我们并购买后,我们为您免费进行无缝搬家服务,让您享受网站零访问延迟的迁移到道勤主机的服务!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

道勤网- 推荐内容!上一条 /2 下一条

!jz_fbzt! !jz_sgzt! !jz_xgzt! 快速回复 !jz_fhlb! !jz_lxwm! !jz_gfqqq!

关于我们|手机版|小黑屋|地图|【道勤网】-www.daoqin.net 软件视频自学教程|免费教程|自学电脑|3D教程|平面教程|影视动画教程|办公教程|机械设计教程|网站设计教程【道勤网】 ( 皖ICP备15000319号-1 )

GMT+8, 2024-4-20 16:55

Powered by DaoQin! X3.4 © 2016-2063 Dao Qin & 道勤科技

快速回复 返回顶部 返回列表