记那些大牌网站的css reset(初始化)样式

何谓css reset ,css reset 的定义

在当今网页设计/开发实践中,使用 CSS来为语义化的(X)HTML标记添加样式风格是重要的关键。在设计师们的梦想中都 存在着这样的一个完美世界:所有的浏览器都能够理解和适用多有CSS规则,并且呈现相同的视觉效果(没有兼容性问题)。但是,我们并没有生活在这个完美的 世界,现实中发生的失窃却总是恰恰相反,很多CSS样式在不同的浏览器中有着不同的解释和呈现。
当今流行的浏览器(如:Firefox、Opera、Internet Explorer、Chrome、Safari等等)中,有一些都是以自己的方式去理解CSS规范,这就会导致有的浏览器对CSS的解释与设计师的CSS 定义初衷相冲突,使得网页的样子在某些浏览器下能正确按照设计师的想法显示,但有些浏览器却并没有按照设计师想要的样子显示出来,这就导致浏览器的兼容性 问题。更糟的是,有的浏览器完全无视CSS的一些声明和属性。
正因为上述冲突和问题依然存在于这个”不完美的世界”,所以一些设计师想到了一种避免浏览器兼容性问题的方法,那就是CSS Reset,什么是CSS Reset?我们可以把它叫做CSS重设,也有人叫做CSS复位、默认CSS、CSS重置等。CSS重设就是由于各种浏览器解释CSS样式的初始值有所不 同,导致设计师在没有定义某个CSS属性时,不同的浏览器会按照自己的默认值来为没有定义的样式赋值,所以我们要先定义好一些CSS样式,来让所有浏览器 都按照同样的规则解释CSS,这样就能避免发生这种问题。

这里我收录了几个国内比较知名的网站的css reset样式,搜狐与土豆网的比较简单,淘宝商城的就相对复杂了一些。具体这个重置样式该怎么用,只能说适合自己的就是最好的!

tmall,淘宝商城

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;}
body,button,input,select,textarea{font:12px/1.5 tahoma,arial,\5b8b\4f53;}
h1,h2,h3,h4,h5,h6{font-size:100%;}
address,cite,dfn,em,var{font-style:normal;}
code,kbd,pre,samp{font-family:courier new,courier,monospace;}
small{font-size:12px;}
ul,ol{list-style:none;}
a{text-decoration:none;}
a:hover{text-decoration:underline;}
sup{vertical-align:text-top;}
sub{vertical-align:text-bottom;}
legend{color:#000;}
fieldset,img{border:0;}
button,input,select,textarea{font-size:100%;}
table{border-collapse:collapse;border-spacing:0;}

tudou,土豆网

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}
body{color:#000;background:#fff;font-size:12px;line-height:1.25;font-family:tahoma,arial,\5b8b\4f53,sans-serif}
th,td{text-align:left;vertical-align:top}
h1,h2,h3,h4,h5,h6{font-size:1em;font-weight:normal}
p{margin:0 0 1em 0}
blockquote{margin:0 0 1em 0}
a{color:#14647d;text-decoration:none;font-family:tahoma,arial,\5b8b\4f53,sans-serif;_font-family:arial,sans-serif}
a:hover{text-decoration:underline}
img{display:block;border:0}
li{list-style:none}
ol{padding:0 0 0 2em}
input,label,select,option,textarea,button,fieldset,legend{font-size:1em;font-family:tahoma,arial,\5b8b\4f53,sans-serif;_font-family:Arial,sans-serif}
input[type=text],textarea{-webkit-appearance:none;-webkit-border-radius:0;outline:none}
input.text{color:#444;border-color:#9f9f9f #dcdcdc #dcdcdc #9f9f9f;border-style:solid;border-width:1px;padding:3px 2px;height:14px}
input.radio,input.checkbox{margin-right:2px;vertical-align:-2px}
input.radio,input.checkbox{margin-left:-2px}
label.radio,label.checkbox{margin-right:5px}
textarea{border-color:#9f9f9f #dcdcdc #dcdcdc #9f9f9f;border-style:solid;border-width:1px;padding:1px;resize:none}

sohu,搜狐网

/* 全局CSS定义 */
body{font-family:’宋体’;text-align:center;margin:0 auto;padding:0;background:#FFF;font-size:12px;color:#333;}
body > div{text-align:center;margin-right:auto;margin-left:auto;}
div,form,ul,ol,li,span,p{margin:0;padding:0;border:0;}
img,a img{border:0;margin:0;padding:0;}
h1,h2,h3,h4,h5,h6{margin:0;padding:0;font-size:12px;font-weight:normal;}
ul,ol,li{list-style:none}
table,td,input{font-size:12px;padding:0}
/* 默认链接颜色 */
a{outline-style:none;color:#333;text-decoration:none}
a:hover{color:#c00;text-decoration:underline;}
/*清除链接虚框*/
/*a,area {blr:expression(this.onFocus=this.blur()) } for IE
:focus {-moz-outline-style: none; } for Firefox
*/

这里记录本人经常用的一种css reset 的样式

html, body, div, span,
h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code,
img, ins, kbd, q, s, samp, small, strike, strong, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baselinebaseline; background: transparent; }
ol, ul {list-style: none; }
blockquote, q {quotes: none;}
blockquote:before, blockquote:after, q:before, q:after {content: ”; content: none; }
table { border-collapse: collapse; border-spacing: 0; }

晴朗网络专注WordPress建站,提供资源和经验分享,欢迎咨询交流!
晴朗网络 » 记那些大牌网站的css reset(初始化)样式