总结属于自己网站的CSS Reset
浏览量:802
yui的css reset很好用,不过对于我来说显得过于臃肿,许多标签都是不常用的,加以修改就可以生成一个精简的属于自己的css reset。
先看yui的css reset
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td { margin:0; padding:0; } table { border-collapse:collapse; border-spacing:0; } fieldset, img { border:0; } address, caption, cite, code, dfn, em, strong, th, var { font-style:normal; font-weight:normal; } ol, ul { list-style:none; } caption, th { text-align:left; } h1, h2, h3, h4, h5, h6 { font-size:100%; font-weight:normal; } q:before, q:after { content:''; } abbr, acronym { border:0; }
既然我们要拥有自己的reset,那么应该根据自己的需求来定义。
首先我们不需要用到blockquote标签,这个标签是引用的作用,默认是会加一个margin属性,达到缩进效果,这个标签我用不到,所以去掉了。
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, th, td { margin:0; padding:0; }
table的reset很好用,必加。
table { border-collapse:collapse; border-spacing:0; }
fieldset的边框是他的特色,我觉得不需要归零,所以去掉了。
img { border:0; }
strong,th默认都是粗体,em是斜体,我觉得没必要统一设置,去掉一些不常用的标签。
caption, cite, code, { font-style:normal; font-weight:normal; }
取消列表样式,必加。
ol, ul { list-style:none; }
关于caption,th的对齐方式,我觉得没必要统一,居中挺好的。
统一h标签为100%,相当于16px,我觉得没必要,取消加粗,也没必要,我觉得H就应该加粗,特殊情况可以后面设置。
q标签表示的是引用,前后会有个引号,不常用的标签。
abbr和acronym标签的语意是缩写,在FF下会有个虚线下划线,html5不支持acronym,留个abbr就够了。
abbr{ border:0; }
这样就生成了自己的css reset
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, th, td { margin:0; padding:0; }
table { border-collapse:collapse; border-spacing:0; }
img,abbr { border:0; }
caption, cite, code, { font-style:normal; font-weight:normal; }
ol, ul { list-style:none; }
-----------------------------------------------------------------------------------------------------------------
根据这些书写,我觉得还是根据自己的情况,根据自己的设计图来归划好能用到的标签就可以了。这样就不会死板的记下特定的CSS Reset了。
在今天上午刚改了CSS Reset.去掉了*{margin:0;padding:0;}的写法。改成:
body,dl,dt,dd,ul,ol,li,strong,p,em,h1,h2,h3,h4,h5,h6,form,input,select,td{margin:0;padding:0;} table{border-collapse:collapse;border-spacing:0;} h1,h2,h3,h4,h5,h6{font-size:100%;} body{font:13px Arial,"宋体";color:#000;text-align:center;} select,input{font-size:12px;} img{vertical-align:middle;border:0;} ol,ul{list-style:none;} a{color:#444;font-size:12px;text-decoration:none;} a:hover{color:#f80;font-size:12px;text-decoration:underline;}