天天看點

CSS重置預設樣式reset.css代碼模闆

CSS重置預設樣式reset.css代碼模闆

由于各大浏覽器存在相容性問題,同一個css屬性在不同浏覽器下的表現不一定相同,有經驗的前端設計者都會自定義一個重置浏覽器樣式的css檔案,在這個檔案中定義一些針對不同的浏覽器最終表現出一緻的代碼。

大家最熟悉的也許就是* {margin:0 0}了,其實這是最簡單的相容性的代碼,一般情況下,僅有這個是不夠的,是以筆者收集了幾個前端設計網站使用的reset.css代碼模闆,如果需要你可以複制這些代碼儲存為reset.css檔案,然後引用在所需的html檔案中即可。

注意:您可以根據您自己的實際情況去修改代碼中選擇器的定義,如果确定用不上代碼中對某些選擇器的定義,可以删除掉。

CSS重置浏覽器樣式代碼一:  

body,ul,li,p,h1,h2,h3,h4,h5,h6,img,br,hr,table,tr,td,dl,dt,dd,form {
  margin: 0;
  padding: 0;
}
body {
  font-family: Arial,"微軟雅黑";
  font-size: 12px;
  color: #434343;
}
.clear {
  clear: both;
  font-size: 0px;
}
ul,li {
  list-style: none;
}
img {
  border: none;
}
/*一般連結*/
a {
  text-decoration: none;
  color: #555;
}
a: hover {
  color: #3366ff;
}      

CSS重置浏覽器代碼二:  

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 { background: transparent; border: 0; margin: 0; padding: 0; vertical-align: baseline; font-size: 100%; font: inherit; -webkit-text-size-adjust: none; }
body { line-height: 1; }
table { border-collapse: collapse; border-spacing: 0; }
object, :focus { outline: none; }
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section /* HTML 5 */ { display: block; }
blockquote, q { quotes: none; }
blockquote:before, blockquote:after, q:before, q:after { content: ‘‘; content: none; }
a img { border: none; }
input,button,textarea,select,optgroup,option{ font-size: 100%; font: inherit; }
.al { text-align: left; }
.ar { text-align: right; }
.ac { text-align: center; }
.lc { margin: 0 auto; }
.fl, .il .fl { float: left; }
.fr, .il .fr { float: right; }
.fc, .il .fc { float: none; clear: both; }
.rel { position: relative; }
.abs { position: absolute; }
.il { list-style: none; }
.il li { float: left; }      

CSS重置浏覽器代碼三:來自Eric Meyer網站:  

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,
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-weight: inherit;
  font-style: inherit;
  font-size: 100%;
  font-family: inherit;
  vertical-align: baseline;
}
: focus {
  outline: 0;
}
body {
  line-height: 1;
  color: black;
  background: white;
}
ol, ul {
  list-style: none;
}
table {
  border-collapse: separate;
  border-spacing: 0;
}
caption, th, td {
  text-align: left;
  font-weight: normal;
}
blockquote: before, blockquote: after,
q: before, q: after {
  content: "";
}
blockquote, q {
  quotes: "" "";
}      

本文完~