首页 > 代码库 > 兼容性-inline-block

兼容性-inline-block

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            display: inline-block;
            background: red;
        }
    </style>
</head>
<body>
    <div>div1</div>
    <div>div2</div>
    <div>div3</div>
</body>
</html>

其他浏览器正常显示一行,IE6/7显示效果如下(不认display:inline-block)

技术分享

可以通过下面方法解决

*display: inline;
*zoom: 1;

div{
            width: 100px;
            height: 100px;
            display: inline-block;
            background: red;
            *display: inline;
            *zoom: 1;
}

 

 

问题2:当设置高度为1px的时候,IE6显示高度为19px,可以通过overflow:hidden解决

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        div{
            height: 1px;
            background: red;
        }
    </style>
</head>
<body>
    <div>div1</div>
</body>
</html>

 

兼容性-inline-block