打造自己的reset.css
来源:广州中睿信息技术有限公司官网
发布时间:2012/10/21 23:25:16 编辑:editor 阅读 314
目前流行的是:目前比较流行的有EricMeyer的重置样式和YUI的重置样式。为什么我们要用重置样式reset.css呢?那是因为在工作中碰到显示要浏览器兼容的问题,而我们希望尽可能的少些浏览器兼容

   目前流行的是:目前比较流行的有Eric Meyer的重置样式和YUI的重置样式。

  为什么我们要用重置样式reset.css呢?那是因为在工作中碰到显示要浏览器兼容的问题,而我们希望尽可能的少些浏览器兼容的代码,可是偏偏不同的浏览器有自己的默认样式,比如li的margin-top在a浏览器里是3px,而在b浏览器里又可能是2px,这样做出来的效果在a浏览器一个样,在b浏览器里又一个样,怎么尽可能地避免这种问题呢,就是自己用"重置样式",尽可能的让要用到的标签的样式由自己来统一,因为开发者为网站设定的样式一般情况下都是是优先于浏览器的默认样式的,所以,如果我们自己为li的margin-top设为2px,那么,现在在a浏览,li的margin-top是2px,在b浏览器里margin-top还是2px,那么不就能把一些浏览器兼容的问题解决了么?当然,浏览器的兼容问题不是能这么轻松就能解决的,但至少,已经能令我们前端开发者少操一些心了...

我是用YUI的重置样式:

  

  /*  Copyright (c) 2010, Yahoo! Inc. All rights reserved.  Code licensed under the BSD License:  http://developer.yahoo.com/yui/license.html  version: 3.3.0  build: 3167  */  /*   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;  }  /*   TODO Figure out where this list-style rule is best set. Hedger has a request to investigate.  */  li {   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;  }  

 1。基础,不要用    

1 * { margin: 0; padding: 0; }

   

2 。默认色彩:不要在reset中设置背景色和文字颜色。

3 。margging和padding:  推荐YUI的做法 。

 4. 边框:推荐用 YUI的。

5.像Eric的,外边框(outline)

1 * remember to define focus styles! */
2 :focus {
3 outline: 0;
4  }
因为喜欢这个,所以选择了这个职业. 是的,现在的我技术不NB,但是干着自己热爱的事情,我每天都灰常滴开心!
联系我们CONTACT 扫一扫
愿景:成为最专业的软件研发服务领航者
中睿信息技术有限公司 广州•深圳 Tel:020-38931912 务实 Pragmatic
广州:广州市天河区翰景路1号金星大厦18层中睿信息 Fax:020-38931912 专业 Professional
深圳:深圳市福田区车公庙有色金属大厦509~510 Tel:0755-25855012 诚信 Integrity
所有权声明:PMI, PMP, Project Management Professional, PMI-ACP, PMI-PBA和PMBOK是项目管理协会(Project Management Institute, Inc.)的注册标志。
版权所有:广州中睿信息技术有限公司 粤ICP备13082838号-2