为什么要Cssreset

1、CssReset是什么?
由于html标签在各浏览器的默认样式解析出来的有所不同。例如<ul>标签在IE、firefox、chrome浏览器下默认边距是不一样的。
各浏览器的默认样,会给我们的页面带来一定的麻烦。同一个标签却显示出不同的效果。所以这就需要统一设置所有浏览器的默认样式。
每个项目都应该会有一个默认样式,这就是cssreset。
例:
button在各浏览器的样式不同


2、CssReset常用的属性有哪些?
(1)、padding、margin;
(2)、border、border-collapse;
(3)、list-style
(4)、font-size
……
3、全局重置
* { padding: 0; margin: 0; border: 0; }
虽然能全部重置,但由于性能较低,不推荐使用。
因为*需要遍历整个DOM树,当页面节点较多时,会影响页面的渲染性能。
通常我们会选中YUI的reset
4、Yahoo(YUI) CSS Reset:

/*
YUI 3.4.1 (build 4118)
Copyright 2011 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/

html{color:#000;background:#FFF}

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}

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;font-variant:normal}

sup{vertical-align:text-top}

sub{vertical-align:text-bottom}

input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit}

input,textarea,select{*font-size:100%}

legend{color:#000}

  

posted on 2015-03-03 19:39  web369  阅读(411)  评论(0编辑  收藏  举报

导航