iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 12
0
自我挑戰組

基礎中的基礎系列系列 第 12

基礎中的基礎之- Css Reset

介紹完css後要來介紹reset

1. 為什麼要用reset?

因為瀏覽器有時會有預設的css樣式,這時用reset就能把預設值歸零(每個瀏覽器預設值不同,但都能透過reset解決這個問題)

  1. css reset到底長怎樣?

別急別急我怕你會嚇到...

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

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, 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,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
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;
}

3.有沒有必要使用css reset?
我個人的建議是:
1.取決你對瀏覽器預設值的依賴程度,如果你的需求剛好需要旁邊留白,或是你的ul前面都需要加一點,那麼你可以考慮不使用reset。
2.取決於你對css熟不熟悉,如果你夠熟悉,那麼其實你可以考慮客製化自己的reset


上一篇
基礎中的基礎之css環境設立
下一篇
基礎中的基礎系列之css權重
系列文
基礎中的基礎系列30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言