IE6-浮动margin产生双倍距离的问题

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<style type="text/css">
	*{padding:0;margin:0;}
	.wrapper{width:500px;margin:0 auto;background:red;}
	.left{float:left;display:inline;width:200px;height:250px;margin-left:50px;background-color:green;}
	.right{float:left;display:inline;width:200px;height:250px;margin-left:50px;background-color:yellow;}
</style>
</head>
<body>
<div class="wrapper">
	<div class="left"></div>
	<div class="right"></div>
</div>
</body>
</html>

自己的理解结合网上知识

解决的方法是给浮动的元素加上display:inline;为什么要加inline呢?

因为left对象是相对于他的父级时才会产生双倍的距离,【只有第一个相对于父级浮动的子元素才会产生双倍的margin】

inline是不存在双倍距离的问题的而且在left对象浮动的时候触发了ie6的特有属性haslayout把inline转换成了inline-block

因为inline-block他是行内块元素他支持给他定义高度宽度和margin我简称他为(伪块元素)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值