分享一下CSS样式重置代码
2017-10-15 19:08
429 查看
通过借鉴网上大牛们的经验和自己在工作中碰到的一些问题,总结出了这些比较常用的CSS样式重置的代码:
@charset "utf-8"; /* 防止用户自定义背景颜色对网页的影响,添加让用户可以自定义字体 */ html{ color: #000; background: #fff; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-size: 100%; } /* IE6对positon:fixed的单独处理修正IE6滚动抖动的bug */ *html,*html body{ background-image:url(about:blank);/*修正IE6滚动抖动的bug*/ background-attachment: fixed;/*根据自己实际,非必需*/ } /* 内外边距通常让各个浏览器样式的表现位置不同 */ body,div,dl,dt,dd,ul,li,pre,form,fieldset,select,input,textarea,button,p,blockquote,th,td,img,iframe{ margin: 0; padding: 0; } body{ width: 100%; } /* 要注意表单元素并不继承父级 font 的问题 */ body,button,input,select,textarea{ font: 12px/1.5 "微软雅黑","Microsoft YaHei","\5b8b\4f53","Tahoma","Arial"; color: #333; outline: none; } input,select,textarea{ font-size: 100%; } /* 重置button边框 */ button{ border: none; } /* 去掉各Table cell 的边距并让其边重合 */ table{ border-collapse: collapse; border-spacing: 0; } /* IE bug fixed: th 不继承 text-align*/ th{ text-align: inherit; } /* 对齐是排版最重要的因素, 别让什么都居中 */ caption,th{ text-align: left; } /* 去除默认边框 */ fieldset,img{ border: none; outline: none; -moz-outline:none; } /* ie6 7 8(q) bug 显示为行内表现 */ iframe{ display: block; } /* 去掉列表前的标识, li 会继承 */ ol,ul,li{ list-style: none; } /* 来自yahoo, 让标题都自定义, 适应多个系统应用 */ h1,h2,h3,h4,h5,h6{ font-size: 100%; font-weight: 500; margin: 0; padding: 0; } /* 让链接默认不显示下划线,在hover状态下显示下划线 */ a{ color: #333; cursor: pointer; outline: none; text-decoration: none; blr:expression(this.onFocus=this.blur()); } a:hover{ text-decoration: underline; } /* 清理浮动 */ .clearfix:before,.clearfix:after{ display: block; content: " "; clear: both; } .clearfix{ zoom: 1; /* for ie67*/ } /* 重设 HTML5 标签, IE 需要在 js 中 createElement(TAG) */ article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{ display: block; } /* HTML5 媒体文件跟 img 保持一致 */ audio,canvas,video{ display: inline-block; *display: inline; *zoom: 1; } address,caption,cite,code,dfn,em,th{ font-style: normal; font-weight: normal; } /*解决盒模型问题css3属性也可用来统一FORM元素风格*/ .box-sizing{ -moz-box-sizing: border-box; -webkit-box-sizing: border-box; -o-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; }
相关文章推荐
- 谁有产品分类的代码,发一个分享一下
- 蛙蛙推荐:最近开发一个小型的OA,把常用代码和大家分享一下先
- 写代码心得分享一下
- 【强烈推荐】分享一下自己的超轻量级高性能O/R mapping数据访问组件Deft,比dapper快20%以上,比手写代码还要快
- C# D3D中2D的使用,做小游戏。。。。半年前写的东西了,拿出来分享,现在看来代码写的乱七八糟的,将就一下吧。。。
- 与大家分享一下200多个js技巧代码,不看别后海呀
- CSS样式重置代码
- C# D3D中2D的使用,做小游戏。。。。半年前写的东西了,拿出来分享,现在看来代码写的乱七八糟的,将就一下吧。。。
- 看着水了一天的群,终于看到一段高质量的代码了分享一下localStorage
- 分享一下程序员必知编写代码规范
- (六)Android分享:代码混淆那些事(转载,原文作者写的比较细致,值得收藏一下,以供以后开发参考)
- [置顶] 分享一下微信支付经验以及JS代码
- 写代码累了放松娱乐一下,在大型生产型企业成功实施工作审批流程项目的经验分享
- 分享一下贝贝成长进度的php代码
- 一道机试题,拿出来和大家分享一下,稍候贴出我做的代码(C#)
- 写代码累了放松娱乐一下,在大型生产型企业成功实施工作审批流程项目的经验分享
- div清除浮动css样式代码分享(4种方法)
- 本人在代码中经常使用到两种控件 highchart 和highstock。现在分享一下两种控件互换方法
- 分享一下基础的汉诺塔问题代码(Java)
- 公司线上的 MySQL 慢日志,之前一直没有做好监控。趁着上周空闲,我就把监控脚本写了下,今天特地把代码发出来与51博友分享一下。 针对脚本的注解和整体构思,我会放到脚本之后为大家