自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

主流瀏覽器CSS Reset的方法

開發(fā) 前端
你知道CSS Reset是什么嗎?通常情況下,它也被寫成Reset CSS,即重設(shè)瀏覽器的樣式,這里向大家簡單描述一下10款瀏覽器CSS Reset的方法,希望對你有所幫助。

本文和大家重點討論一下主流瀏覽器CSS Reset的方法,在各種瀏覽器中,都會對CSS的選擇器默認一些數(shù)值,有了CSS Reset以后會讓網(wǎng)頁的樣式在各瀏覽器中表現(xiàn)一致。

主流瀏覽器CSS Reset的方法

知道CSS Reset是什么嗎?通常情況下,它也被寫成Reset CSS,即重設(shè)瀏覽器的樣式。在各種瀏覽器中,都會對CSS的選擇器默認一些數(shù)值,譬如當h1沒有被設(shè)置數(shù)值時,顯示一定大小。但并不是所有的瀏覽器都使用一樣的數(shù)值,所以,有了CSS Reset,以讓網(wǎng)頁的樣式在各瀏覽器中表現(xiàn)一致。

正在使用CSS的你,用過CSS Reset嗎?當然,或許你用了,卻不知道正在用,比如你可能用到: 

  1. *{padding:0;margin:0;border:0;}  
  2.  

這也是一款CSS Reset的方法,讓所有的選擇器的padding、margin和border都設(shè)置成0。這是一種強大的方法,也是最簡單,最安全的方法,不過,也是最占用資源的方法。對于小型的網(wǎng)站來說,用這個并不會帶來大的資源浪費,但如果是像Yahoo這種架構(gòu)非常大的網(wǎng)站,剛需要有選擇地進行CSS重設(shè),以減少資源浪費。下面是Yahoo的CSS重設(shè)代碼,也是受最多人喜愛的CSS Reset方法,YUI選擇的方法是:

  1. body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,  
  2. form,fieldset,input,textarea,p,blockquote,th,td{  
  3. padding:0;  
  4. margin:0;  
  5. }  
  6. table{  
  7. border-collapse:collapse;  
  8. border-spacing:0;  
  9. }  
  10. fieldset,img{  
  11. border:0;  
  12. }  
  13. address,caption,cite,code,dfn,em,strong,th,var{  
  14. font-weight:normal;  
  15. font-style:normal;  
  16. }  
  17. ol,ul{  
  18. list-style:none;  
  19. }  
  20. caption,th{  
  21. text-align:left;  
  22. }  
  23. h1,h2,h3,h4,h5,h6{  
  24. font-weight:normal;  
  25. font-size:100%;  
  26. }  
  27. q:before,q:after{  
  28. content:”;  
  29. }  
  30. abbr,acronym{border:0;  
  31. }  
  32.  

 #p#OK,相信你也已經(jīng)了解了CSS重設(shè)的目的,或許你也可以根據(jù)自己的喜好,寫一個自己的CSS重設(shè)系統(tǒng),畢竟大家的需求和習(xí)慣的不同的。而你可以參照下面的幾款:

 AteneuPopularCSS Reset

  1.  html,body,div,span,applet,object,iframe,h1,h2,h3,  
  2. h4,h5,h6,p,blockquote,pre,a,abbr,acronym,  
  3. address,big,cite,code,del,dfn,em,font,img,ins,  
  4. kbd,q,s,samp,small,strike,strong,sub,sup,tt,  
  5. var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,  
  6. table,caption,tbody,tfoot,thead,tr,th,td{  
  7. margin:0;  
  8. padding:0;  
  9. border:0;  
  10. outline:0;  
  11. font-weight:inherit;  
  12. font-style:inherit;  
  13. font-size:100%;  
  14. font-family:inherit;  
  15. vertical-align:baseline;  
  16. }  
  17. :focus{outline:0;}  
  18. a,a:link,a:visited,a:hover,a:active{text-decoration:none}  
  19. table{border-collapse:separate;border-spacing:0;}  
  20. th,td{text-align:left;font-weight:normal;}  
  21. img,iframe{border:none;text-decoration:none;}  
  22. ol,ul{list-style:none;}  
  23. input,textarea,select,button{font-size:100%;font-family:inherit;}  
  24. select{margin:inherit;}  
  25. hr{margin:0;padding:0;border:0;color:#000;background-color:#000;height:1px} 

ChrisPoteet’sReset CSS

  1. *{  
  2. vertical-align:baseline;  
  3. font-family:inherit;  
  4. font-style:inherit;  
  5. font-size:100%;  
  6. border:none;  
  7. padding:0;  
  8. margin:0;  
  9. }  
  10. body{  
  11. padding:5px;  
  12. }  
  13. h1,h2,h3,h4,h5,h6,p,pre,blockquote,form,ul,ol,dl{  
  14. margin:20px0;  
  15. }  
  16. li,dd,blockquote{  
  17. margin-left:40px;  
  18. }  
  19. table{  
  20. border-collapse:collapse;  
  21. border-spacing:0;  
  22. }  
  23.  

 #p#EricMeyerReset CSS

  1. html,body,div,span,applet,object,iframe,table,caption,  
  2. tbody,tfoot,thead,tr,th,td,del,dfn,em,font,img,ins,  
  3. kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,  
  4. h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,  
  5. acronym,address,big,cite,code,dl,dt,dd,ol,ul,li,  
  6. fieldset,form,label,legend{  
  7. vertical-align:baseline;  
  8. font-family:inherit;  
  9. font-weight:inherit;  
  10. font-style:inherit;  
  11. font-size:100%;  
  12. outline:0;  
  13. padding:0;  
  14. margin:0;  
  15. border:0;  
  16. }  
  17. :focus{  
  18. outline:0;  
  19. }  
  20. body{  
  21. background:white;  
  22. line-height:1;  
  23. color:black;  
  24. }  
  25. ol,ul{  
  26. list-style:none;  
  27. }  
  28. table{  
  29. border-collapse:separate;  
  30. border-spacing:0;  
  31. }  
  32. caption,th,td{  
  33. font-weight:normal;  
  34. text-align:left;  
  35. }  
  36. blockquote:before,blockquote:after,q:before,q:after{  
  37. content:"";  
  38. }  
  39. blockquote,q{  
  40. quotes:"""";  
  41. }  
  42.  

 TantekCelikReset CSS 

  1. :link,:visited{text-decoration:none}  
  2. ul,ol{list-style:none}  
  3. h1,h2,h3,h4,h5,h6,pre,code{font-size:1em;}  
  4. ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input  
  5. {margin:0;padding:0}  
  6. aimg,:linkimg,:visitedimg{border:none}  
  7. address{font-style:normal}  
  8.  

ChristianMontoyaResetCSS

  1. html,body,form,fieldset{  
  2. margin:0;  
  3. padding:0;  
  4. font:100%/120%Verdana,Arial,Helvetica,sans-serif;  
  5. }  
  6. h1,h2,h3,h4,h5,h6,p,pre,  
  7. blockquote,ul,ol,dl,address{  
  8. margin:1em0;  
  9. padding:0;  
  10. }  
  11. li,dd,blockquote{  
  12. margin-left:1em;  
  13. }  
  14. formlabel{  
  15. cursor:pointer;  
  16. }  
  17. fieldset{  
  18. border:none;  
  19. }  
  20. input,select,textarea{  
  21. font-size:100%;  
  22. font-family:inherit;  
  23. }  
  24.  

#p#RudeworksResetCSS
 

  1. *{  
  2. margin:0;  
  3. padding:0;  
  4. border:none;  
  5. }  
  6. html{  
  7. font:62.5%"LucidaGrande",Lucida,Verdana,sans-serif;  
  8. text-shadow:#0000px0px0px;  
  9. }  
  10. ul{  
  11. list-style:none;  
  12. list-style-type:none;  
  13. }  
  14. h1,h2,h3,h4,h5,h6,p,pre,  
  15. blockquote,ul,ol,dl,address{  
  16. font-weight:normal;  
  17. margin:001em0;  
  18. }  
  19. cite,em,dfn{  
  20. font-style:italic;  
  21. }  
  22. sup{  
  23. position:relative;  
  24. bottom:0.3em;  
  25. vertical-align:baseline;  
  26. }  
  27. sub{  
  28. position:relative;  
  29. bottom:-0.2em;  
  30. vertical-align:baseline;  
  31. }  
  32. li,dd,blockquote{  
  33. margin-left:1em;  
  34. }  
  35. code,kbd,samp,pre,tt,var,input[type='text'],textarea{  
  36. font-size:100%;  
  37. font-family:monaco,"LucidaConsole",courier,mono-space;  
  38. }  
  39. del{  
  40. text-decoration:line-through;  
  41. }  
  42. ins,dfn{  
  43. border-bottom:1pxsolid#ccc;  
  44. }  
  45. small,sup,sub{  
  46. font-size:85%;  
  47. }  
  48. abbr,acronym{  
  49. text-transform:uppercase;  
  50. font-size:85%;  
  51. letter-spacing:.1em;  
  52. border-bottom-style:dotted;  
  53. border-bottom-width:1px;  
  54. }  
  55. aabbr,aacronym{  
  56. border:none;  
  57. }  
  58. sup{  
  59. vertical-align:super;  
  60. }  
  61. sub{  
  62. vertical-align:sub;  
  63. }  
  64. h1{  
  65. font-size:2em;  
  66. }  
  67. h2{  
  68. font-size:1.8em;  
  69. }  
  70. h3{  
  71. font-size:1.6em;  
  72. }  
  73. h4{  
  74. font-size:1.4em;  
  75. }  
  76. h5{  
  77. font-size:1.2em;  
  78. }  
  79. h6{  
  80. font-size:1em;  
  81. }  
  82. a,a:link,a:visited,a:hover,a:active{  
  83. outline:0;  
  84. text-decoration:none;  
  85. }  
  86. aimg{  
  87. border:none;  
  88. text-decoration:none;  
  89. }  
  90. img{  
  91. border:none;  
  92. text-decoration:none;  
  93. }  
  94. label,button{  
  95. cursor:pointer;  
  96. }  
  97. input:focus,select:focus,textarea:focus{  
  98. background-color:#FFF;  
  99. }  
  100. fieldset{  
  101. border:none;  
  102. }  
  103. .clear{  
  104. clear:both;  
  105. }  
  106. .float-left{  
  107. float:left;  
  108. }  
  109. .float-right{  
  110. float:right;  
  111. }  
  112. body{  
  113. text-align:center;  
  114. }  
  115. #wrapper{  
  116. margin:0auto;  
  117. text-align:left;  
  118. }  
  119.  

 #p#Anieto2KReset CSS 

  1. html,body,div,span,applet,object,iframe,  
  2. h1,h2,h3,h4,h5,h6,p,  
  3. blockquote,pre,a,abbr,acronym,address,big,  
  4. cite,code,del,dfn,em,font,img,  
  5. ins,kbd,q,s,samp,small,strike,  
  6. strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,  
  7. fieldset,form,label,legend,  
  8. table,caption,tbody,tfoot,thead,tr,th,td,  
  9. center,u,b,i{  
  10. margin:0;  
  11. padding:0;  
  12. border:0;  
  13. outline:0;  
  14. font-weight:normal;  
  15. font-style:normal;  
  16. font-size:100%;  
  17. font-family:inherit;  
  18. vertical-align:baseline  
  19. }  
  20. body{  
  21. line-height:1  
  22. }  
  23. :focus{  
  24. outline:0  
  25. }  
  26. ol,ul{  
  27. list-style:none  
  28. }  
  29. table{  
  30. border-collapse:collapse;  
  31. border-spacing:0  
  32. }  
  33. blockquote:before,blockquote:after,q:before,q:after{  
  34. content:""  
  35. }  
  36. blockquote,q{  
  37. quotes:""""  
  38. }  
  39. input,textarea{  
  40. margin:0;  
  41. padding:0  
  42. }  
  43. hr{  
  44. margin:0;  
  45. padding:0;  
  46. border:0;  
  47. color:#000;  
  48. background-color:#000;  
  49. height:1px  
  50. }  
  51.  

 CSSLabCSS Reset

  1. html,body,div,span,applet,object,iframe,h1,h2,h3,  
  2. h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,  
  3. big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,  
  4. small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,  
  5. fieldset,form,label,legend,table,caption,tbody,tfoot,  
  6. thead,tr,th,td{  
  7. margin:0;  
  8. padding:0;  
  9. border:0;  
  10. outline:0;  
  11. font-weight:inherit;  
  12. font-style:inherit;  
  13. font-size:100%;  
  14. font-family:inherit;  
  15. vertical-align:baseline;  
  16. }  
  17. :focus{  
  18. outline:0;  
  19. }  
  20. table{  
  21. border-collapse:separate;  
  22. border-spacing:0;  
  23. }  
  24. caption,th,td{  
  25. text-align:left;  
  26. font-weight:normal;  
  27. }  
  28. aimg,iframe{  
  29. border:none;  
  30. }  
  31. ol,ul{  
  32. list-style:none;  
  33. }  
  34. input,textarea,select,button{  
  35. font-size:100%;  
  36. font-family:inherit;  
  37. }  
  38. select{  
  39. margin:inherit;  
  40. }  
  41. /*Fixesincorrectplacementofnumbersinol’sinIE6/7*/  
  42. ol{margin-left:2em;}  
  43. /*==clearfix==*/  
  44. .clearfix:after{  
  45. content:".";  
  46. display:block;  
  47. height:0;  
  48. clear:both;  
  49. visibility:hidden;  
  50. }  
  51. .clearfix{display:inline-block;}  
  52. *html.clearfix{height:1%;}  
  53. .clearfix{display:block;}  
  54.  

像你看到的,這些都大同小異,需求不同,方法也就不同。我自己偏向于喜歡Yahoo的CSS Reset,也用了Yahoo的代碼。你,有自己的CSS Reset體系嗎?或許可以分享出來!

CSS Reset代碼來源:10TécnicasparaResetCSS

【編輯推薦】

  1. 探究瀏覽器Firefox與IE在CSS樣式表中的差異
  2. 區(qū)分IE6 IE7和IE8瀏覽器行之有效的辦法
  3. 剖析Margin和Padding屬性中四個值的先后順序及區(qū)別
  4. 九步輕松解決IE6的各種疑難雜癥
  5. 技術(shù)前沿 一段JS代碼輕松解決IE6-IE8的兼容性問題

 

責任編輯:佚名 來源: div-css.com
相關(guān)推薦

2010-08-31 16:49:58

2023-09-05 09:44:26

CSS處理器函數(shù)

2023-09-05 09:40:55

SCSS預(yù)處理器

2010-04-01 13:03:10

2009-07-24 15:29:11

支持CSS3

2009-04-16 08:30:59

2011-02-23 10:17:49

瀏覽器OperaSafari

2009-03-12 08:52:12

瀏覽器競爭

2013-02-21 15:56:18

瀏覽器遨游

2023-03-01 00:06:14

JavaScrip框架CSS

2009-05-27 08:52:05

2009-03-19 09:16:36

瀏覽器性能測試Chrome

2011-08-10 14:05:53

瀏覽器

2010-08-30 15:40:31

CSS瀏覽器兼容

2010-08-20 14:11:26

IE火狐瀏覽器

2010-09-14 14:18:09

CSS跨瀏覽器開發(fā)

2010-06-23 13:24:00

CSSCSS選擇器

2013-11-20 13:04:41

css瀏覽器渲染

2010-09-15 15:39:03

CSS hack

2009-03-10 08:31:33

Lunascape瀏覽器
點贊
收藏

51CTO技術(shù)棧公眾號