CSS样式重置和清除(让不同浏览器显示效果一致)
发布时间:2013-05-20 18:02:38 作者:佚名
我要评论
CSS样式清除和重置是前端开发必需要做的事情,结合了前辈们的经验整理了一份CSS重置样式代码不敢独享特此与大家分享下,感兴趣的朋友可不要错过了哈
为了让页面在各不同浏览器之间显示效果一致,CSS样式清除和重置是前端开发必需要做的事情,结合前车之鉴,整理了份CSS重置样式代码供参考。
@charset "utf-8";
body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, pre,
dl, dt, dd, ul, ol, li, th, td, div, span, img,
fieldset, lengend, button, input, select, textarea{margin: 0;padding: 0;}
/* color & background */
html{color:#000; background:#FFF;}
/* font */
body, button, input, select, textarea { /* for ie */
font: 12px/18px Arial, Verdana, Microsoft YaHei;
}
/* fix center */
html,body {height: 100%;margin: 0 auto;}
/* h1~h6 */
h1 {font-size: 18px;}
h2 {font-size: 16px;}
h3 {font-size: 14px;}
h4, h5, h6 {font-size: 100%;}
/* a */
a { text-decoration: none; }
a:hover { text-decoration: underline; }
/* list */
ul,ol {list-style: none;}
/* img border */
fieldset,img{border: 0}
/* table */
table {border-collapse: collapse;border-spacing: 0;font:inherit;}
/* margin */
.alpha {margin-left: 0;}
.omega {margin-right: 0;}
/* float & clear */
.left{float:left;}
.right{float:right;}
.clear {clear: both;display: block;}
/* clearfix */
.clearfix:after{content:".";display:block;}
.clearfix{display:inline-table;}
/* Hides from IE-mac */
* html .clearfix{height:1%;}
.clearfix{display:block;}
/* End hide from IE-mac */
*+html .clearfix{min-height:1%;}/* IE7 */
复制代码
代码如下:@charset "utf-8";
body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, pre,
dl, dt, dd, ul, ol, li, th, td, div, span, img,
fieldset, lengend, button, input, select, textarea{margin: 0;padding: 0;}
/* color & background */
html{color:#000; background:#FFF;}
/* font */
body, button, input, select, textarea { /* for ie */
font: 12px/18px Arial, Verdana, Microsoft YaHei;
}
/* fix center */
html,body {height: 100%;margin: 0 auto;}
/* h1~h6 */
h1 {font-size: 18px;}
h2 {font-size: 16px;}
h3 {font-size: 14px;}
h4, h5, h6 {font-size: 100%;}
/* a */
a { text-decoration: none; }
a:hover { text-decoration: underline; }
/* list */
ul,ol {list-style: none;}
/* img border */
fieldset,img{border: 0}
/* table */
table {border-collapse: collapse;border-spacing: 0;font:inherit;}
/* margin */
.alpha {margin-left: 0;}
.omega {margin-right: 0;}
/* float & clear */
.left{float:left;}
.right{float:right;}
.clear {clear: both;display: block;}
/* clearfix */
.clearfix:after{content:".";display:block;}
.clearfix{display:inline-table;}
/* Hides from IE-mac */
* html .clearfix{height:1%;}
.clearfix{display:block;}
/* End hide from IE-mac */
*+html .clearfix{min-height:1%;}/* IE7 */
相关文章
- 每个浏览器都有一套CSS样式表用于保证网页正常显示,为了精准写出WEB页面 通常一开始就重新定义标签样式,介绍两个比较不错的Reset.css 分别来自雅虎YUI和Eric Meyer2014-01-26
- 全局CSS想必大家并不陌生吧,主要就是一些基础全局的样式设置,提高书写效率,本文整理了一些方便大家使用,感兴趣的朋友可以了解下2013-09-12
CSS重置(CSS Reset) 让网页样式在各浏览器中表现一致
CSS Reset是指重设浏览器的样式,在各种浏览器中,都会对CSS的选择器默认一些数值,譬如当h1没有被设置数值时,显示一定大小;有了CSS Reset,让网页的样式在各浏览器中表现2012-12-21- reset.css本意就是重置样式,我始终建议把.clearfix放入layout.css,而把h1、h2之类的定义放进typography.css2012-04-01
- 网页制作Webjx文章简介:Eric Meyer Reset和YUI Reset都是非常强大的,但是对于我而言,它们走的太远了。我觉得你最终需要重置一切,然后重新定义所有元素的属性。这就是为2009-04-02
- 网页制作Webjx文章简介:本文就是来介绍如何写一个合适所有项目的通用的reset.css,以及介绍在设置玩reset.css之后需要针对不同项目要首先要设置的内容。2009-04-02
- 这篇文章主要介绍了CSS样式重置代码,一般保存为reset.css修改了默认的css设置,方便布局与提高浏览器兼容性2014-06-11


最新评论