分享一下CSS样式重置代码

通过借鉴网上大牛们的经验和自己在工作中碰到的一些问题,总结出了这些比较常用的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;
}
复制代码
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值