Css Reset(样式复位)

一些标签元素在HTML下有一个默认属性值,我们在写css页面的时候,为了避免在css中重复定义它们,我们需要重置默认样式(css reset)。每个人的用法和写法都不一样。一篇关于 css reset的调查文章, 可以看看国外使用css reset的比例调查。

 

原文地址: http://perishablepress.com/press/2007/10/23/a-killer-collection-of-global-css-reset-styles/
转载注明出处:http://www.css88.com/article.asp?id=500

相信这一段你经常看到.而且也是我们经常用到的。

* { margin : 0 ;
padding
: 0 ;
}

 

这是作者当前比较钟意的一种写法.保证了相对普遍浏览器样式的统一性.

{     
 vertical-align
:  baselinebaseline ;     
 font-weight
:  inherit ;     
 font-family
:  inherit ;     
 font-style
:  inherit ;     
 font-size
:  100% ;     
 border
:  0 none ;     
 outline
:  0 ;     
 padding
:  0 ;     
 margin
:  0 ;     
 
}  


其实这也是我们常用的一类Css Reset.对字体的大小复位,以及图片链接的边框处理.
也经常在某些站点看到

html, body  {     
 padding
:  0 ;     
 margin
:  0 ;     
 
}     
html 
{     
 font-size
:  1em ;     
 
}     
body 
{     
 font-size
:  100% ;     
 
}     
a img, :link img, :visited img 
{     
 border
:  0 ;     
 
}

作者认为Shaun写这类的Css Reset是有某种目的性.
而且这类规则是针对的是某些重要的常用浏览器.
比如ie,firefox等
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre,     
form, fieldset, input, p, blockquote, table, th, td, embed, object 
{     
 padding
:  0 ;     
 margin
:  0 ;      
 
}     
table 
{     
 border-collapse
:  collapse ;     
 border-spacing
:  0 ;     
 
}     
fieldset, img, abbr 
{     
 border
:  0 ;     
 
}     
address, caption, cite, code, dfn, em,     
h1, h2, h3, h4, h5, h6, strong, th, var 
{     
 font-weight
:  normal ;     
 font-style
:  normal ;     
 
}     
ul 
{     
 list-style
:  none ;     
 
}     
caption, th 
{     
 text-align
:  left ;     
 
}     
h1, h2, h3, h4, h5, h6 
{     
 font-size
:  1.0em ;     
 
}     
q:before, q:after 
{     
 content
:  '' ;     
 
}     
a, ins 
{     
 text-decoration
:  none ;     
 
}

 

yahoo这帮家伙写的Reset个人觉得可以推荐

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 ;     
 
}  

 

作者将Erik Meyer的代码重新整理了.但功能上还是一样的
这套Css Reset是业内是使用最多的 
html, body, div, span, applet, object, iframe, table, caption, tbody, tfoot, thead, tr, th, td,     
del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var,     
h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code,     
dl, dt, dd, ol, ul, li, fieldset, form, label, legend 
{     
 vertical-align
:  baselinebaseline ;     
 font-family
:  inherit ;     
 font-weight
:  inherit ;     
 font-style
:  inherit ;     
 font-size
:  100% ;     
 outline
:  0 ;     
 padding
:  0 ;     
 margin
:  0 ;     
 border
:  0 ;     
 
}     
/*  remember to define focus styles!  */    
:focus 
{     
 outline
:  0 ;     
 
}     
body 
{     
 background
:  white ;     
 line-height
:  1 ;     
 color
:  black ;     
 
}     
ol, ul 
{     
 list-style
:  none ;     
 
}     
/*  tables still need cellspacing="0" in the markup  */    
table 
{     
 border-collapse
:  separate ;     
 border-spacing
:  0 ;     
 
}     
caption, th, td 
{     
 font-weight
:  normal ;     
 text-align
:  left ;     
 
}     
/*  remove possible quote marks (") from <q> & <blockquote>  */    
blockquote:before, blockquote:after, q:before, q:after 
{     
 content
:  "" ;    
 
}    
blockquote, q 
{    
 quotes
:  "" "" ;     
 
}

转载于:https://www.cnblogs.com/joe235/archive/2008/11/21/1335667.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值