css样式初始化

原因:不同的浏览器对各个元素的margin,padding,borer,font等属性的定义各有不同,不同浏览器的显示效果可能不一样,为杜绝这种情况,通过css强制让所有元素的属性值都一样,这样浏览器显示就一致了,减少不兼容情况的发生,这个过程叫css的初始。

代码:

@charset "utf-8";
/* CSS Document */

*{
	box-sizing:border-box;
	-moz-box-sizing:border-box;/*兼容低版本的浏览器*/
	-webkit-box-sizing:border-box;/*为了兼容低版本的web*/
	color:#000;
}
body{
	font-size:12px;
	font-family:Arial,Verdana,Tahoma,"微软雅黑","黑体";
	line-height:120%;
	background:#fff;
	margin:0;
	overflow-x:hidden;/*溢出隐藏,去掉水平方向的,直接剪裁*/
}
p,h1,h2,h3,h4,h5,h6,ul,ol,dl,li,form,table{
	margin:0;
	padding:0;
}
a,img{
	border:none;/*兼容ie浏览器*/
}
img{
	vertical-align:middle;
	border:0;
}
li{
	list-style:none;
}
i,em{
	font-style:normal;
}
a{
	text-decoration:none; 
	color:#000000;
	border:0;
}
a:link{
	text-decoration:none; 
	color:#000000;
}
a:visited{
	text-decoration:none; 
	color:#000000;
}
a:hover{
	text-decoration:none; 
	color:#000000;
}
a:active{
	text-decoration:none; 
	color:#000000;
}
.clearfix:before,.clearfix:after{
	display:table;
	content:"";
}
.clearfix:after{
	clear:both;
}
.clearfix{
	*zoom:1;
}/*兼容ie浏览器*/
table{border-collapse:collapse;}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值