CSS Reset(CSS重設)

來源:互聯網
上載者:User

標籤:style   blog   http   color   使用   strong   

  CSS Reset是指重設瀏覽器的樣式。在各種瀏覽器中,都會對CSS的選取器預設一些數值,譬如當h1沒有被設定數值時,顯示一定大小。

  但並不是所有的瀏覽器都使用一樣的數值,所以有了CSS Reset,以讓網頁的樣式在各瀏覽器中表現一致。

  下面介紹幾個主流的CSS Reset代碼:

  1、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, 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;  }

 

  2、YUI

  

/*  YUI 3.4.1 (build 4118)  Copyright 2011 Yahoo! Inc. All rights reserved.  Licensed under the BSD License.  http://yuilibrary.com/license/  */  /*  TODO will need to remove settings on HTML since we can’t namespace it.  TODO with the prefix,should I group by selector or property for weight savings?  */  html {  color:#000;  background:#FFF;  }  /*  TODO remove settings on BODY since we can’t namespace it.  */  /*  TODO test putting a class on HEAD.  - Fails on FF.  */  body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td {  margin:0;  padding:0;  }  table {  border-collapse:collapse;  border-spacing:0;  }  fieldset,img {  border:0;  }  /*  TODO think about hanlding inheritence differently,maybe letting IE6 fail a bit…  */  address,caption,cite,code,dfn,em,strong,th,var {  font-style:normal;  font-weight:normal;  }  ol,ul {  list-style:none;  }  caption,th {  text-align:left;  }  h1,h2,h3,h4,h5,h6 {  font-size:100%;  font-weight:normal;  }  q:before,q:after {  content:‘‘;  }  abbr,acronym {  border:0;  font-variant:normal;  }  /* to preserve line-height and selector appearance */  sup {  vertical-align:text-top;  }  sub {  vertical-align:text-bottom;  }  input,textarea,select {  font-family:inherit;  font-size:inherit;  font-weight:inherit;  }  /*to enable resizing for IE*/  input,textarea,select {  *font-size:100%;  }  /*because legend doesn’t inherit in IE */  legend {  color:#000;  }

  3、csslab

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, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td,  article, aside, dialog, figure, header, footer, hgroup, menu, nav, section, time, mark, audio, video {  margin: 0;  padding: 0;  border: 0;  outline: 0;  font-weight: inherit;  font-style: inherit;  font-size: 100%;  }  article, aside, nav, section, dialog, figure, header, footer, hgroup {  display:block;  }  legend {  display:none;  }  :focus {  outline: 0;  }  table {  border-collapse: collapse;  border-spacing: 0;  }  caption, th, td {  text-align: left;  font-weight: normal;  }  a img, iframe {  border: none;  }  ul {  list-style: none;  }  input, textarea, select, button {  font-size: 100%;  font-family: inherit;  }  input, select {  vertical-align:middle;  }  select {  margin: inherit;  }  button {  border: 0;  padding: 0;  background: transparent;  cursor: pointer;  }  /* Fixes incorrect placement of numbers in ol’s in IE6/7 */  ol { margin-left:2em; }  /* ========================================= clearfix == */  .clearfix:after {  content: ".";  display: block;  height: 0;  clear: both;  visibility: hidden;  }  .clearfix {display: inline-block;}  * html .clearfix {height: 1%;}  .clearfix {display: block;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.