码迷,mamicode.com
首页 > 其他好文 > 详细

inline-block在ie6中的经典bug

时间:2015-04-12 22:37:40      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

众所周知,给元素设置 inline-block ,可以让ie下的元素出发layout:1。

但是,当给元素设置 inline-block 后,在另外一个class 样式(非设置inline-block的class样式)重置为inline或者block。对于ie6下,该元素还会保留触发 layout:1;的效果。

例:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<style>
  .box a{display:inline-block;width:30%;background:#ccc;text-align:center;}
  .box .fl{float:left;background:red;}
  .box .fr{float:right;background:red;}
  .box .center{display:block;}
</style>
<div class="box">
  <a href="#" class="fl">left</a>
  <a href="#" class="fr">right</a>
  <a href="#" class="center">center</a>
</div>
</body>
</html>

   在ie6下面会发现中间的模块会和左右模块之间有间距,可以看到白色背景。

这个bug就是inline-block样式引起的,虽然后来在 .box .center 样式中重置为block,但是该模块还是保留了layout:1;的属性。

 

解决办法:  

<style>
.box a{width:30%;background:#ccc;text-align:center;}
.box .fl{float:left;display:inline-block;background:red;}
.box .fr{float:right;display:inline-block;background:red;}
.box .center{display:block;}
</style>

  

inline-block在ie6中的经典bug

标签:

原文地址:http://www.cnblogs.com/ayseeing/p/4420550.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!