正在使用CSS的你,用過(guò)CSS Reset嗎?當(dāng)然,或許你用了,卻不知道正在用,比如你可能用到:
| * { padding: 0; margin: 0; border: 0; } |
這也是一款CSS Reset的方法,讓所有的選擇器的padding、margin和border都設(shè)置成0。這是一種強(qiáng)大的方法,也是最簡(jiǎn)單,最安全的方法,不過(guò),也是 最占用資源的方法。對(duì)于小型的網(wǎng)站來(lái)說(shuō),用這個(gè)并不會(huì)帶來(lái)大的資源浪費(fèi),但如果是像Yahoo這種架構(gòu)非常大的網(wǎng)站,剛需要有選擇地進(jìn)行CSS重設(shè),以減 少資源浪費(fèi)。下面是Yahoo的CSS重設(shè)代碼,也是受最多人喜愛(ài)的CSS Reset方法,YUI選擇的方法是:
| body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre, form,fieldset,input,textarea,p,blockquote,th,td { padding: 0; margin: 0; } table { border-collapse: collapse; border-spacing: 0; } fieldset,img { border: 0; } address,caption,cite,code,dfn,em,strong,th,var { font-weight: normal; font-style: normal; } ol,ul { list-style: none; } caption,th { text-align: left; } h1,h2,h3,h4,h5,h6 { font-weight: normal; font-size: 100%; } q:before,q:after { content:”; } abbr,acronym { border: 0; } |
OK,相信你也已經(jīng)了解了CSS重設(shè)的目的,或許你也可以根據(jù)自己的喜好,寫一個(gè)自己的CSS重設(shè)系統(tǒng),畢竟大家的需求和習(xí)慣的不同的。而你可以參照下面的幾款:
Ateneu Popular CSS Reset
| 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;} a, a:link, a:visited, a:hover, a:active{text-decoration:none} table { border-collapse: separate;border-spacing: 0;} th, td {text-align: left; font-weight: normal;} img, iframe {border: none; text-decoration:none;} ol, ul {list-style: none;} input, textarea, select, button {font-size: 100%;font-family: inherit;} select {margin: inherit;} hr {margin: 0;padding: 0;border: 0;color: #000;background-color: #000;height: 1px} |
新聞熱點(diǎn)
疑難解答
圖片精選