CSS Reset 或 Reset CSS,CSS重置,CSS重设,CSS复位,默认CSS… 怎么叫都可以。每个浏览器会对HTML标记有自己默认的CSS样式定义,为了达到高度和谐的统一,先通过Reset CSS把所有的元素样式都定义为统一标准了,再去基于自定义的这个标准书写接下来的CSS。我以前碰过一些朋友老是问布局在IE下错乱的非常诡异,有的时候可能就是没进行Reset CSS,而浏览器写了一些你没看到的代码,就乱七八糟了。
比如我们最常用的就是
*{margin:0;padding:0;}
最近又开始用(不过据说很不科学)
*{margin:0;padding:0;border:0;outline:0;vertical-align:baseline;background:transparent;}
应该每个写CSS的人都会写到Reset作用的CSS吧,只是可能和我一样不知道是叫这个名字下面是比较全的CSS重置
/* v1.0 | 20080212 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
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: baseline;
background: transparent;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
/* remember to define focus styles! */
:focus {
outline: 0;
}
/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}
/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}