- 不要盲目相信主流说法,*{margin:0;padding:0}或reset.css使用的margin和padding重置方法。大多数reset.css中的代码都是不需要的,让我们来试验下。body)
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0}
ff:ie:
gg:
可见body的margin:0;是需要的,而padding:0;是不需要的。
div)
ff:ie:
gg:
可见div的margin和padding的重置都是不需要的。
根据以上方法最后整理出一个自己的margin和padding:body,dl,dd,ul,ol,h1,h2,h3,h4,h5,h6,pre,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0} filedset{padding:0;border:0}
- 根据自己的实验,参考YUI的cssreset整理出自己的reset.css文件,压缩后体积较原来小了很多。仅供参考:
/**css reset * @author maqunjing * @date 2012-7-25 * */ body, dl, dd, h1, h2, h3, h4, h5, h6, pre, p, blockquote, fieldset, textarea, ol, ul { margin: 0 } fieldset, textarea, input, a img { border: none } fieldset, textarea, input, legend, th, td, ol, ul { padding: 0 } address, caption, cite, code, dfn, em, strong, th, var, optgroup { font-style: normal } th, strong, optgroup, h1, h2, h3, h4, h5, h6 { font-weight: normal } ol, ul { list-style: none } caption, th { text-align: left } h1, h2, h3, h4, h5, h6, sup, sub { font-size: 100% } input, textarea, select, button, optgroup, option { font-family: inherit; font-size: inherit; font-weight: inherit; font-style: inherit } input, button, textarea, select, optgroup, option { *font-size: 100% } code, kbd, samp { font-family: inherit } table { border-collapse: collapse; border-spacing: 0 } sup, sub { vertical-align: baseline; } q:before, q:after { content: '' } :link, :visited, ins { text-decoration: none } :focus { outline: 0 }
相关文章: