首页 > 其他 > 详细

兼容性—IE6/7下当li里面的元素都浮动,li之间会产生4px的缝隙

时间:2017-05-14 18:27:29      阅读:277      评论:0      收藏:0      [点我收藏+]

代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        ul{
            margin: 0px;
            padding: 0px;
            width: 300px;
            list-style: none;
        }
        li{
            height: 30px;
            line-height: 30px;
            border:1px solid red;
        }
        ul li a{
            float: left;
            text-decoration: none;
        }
        ul li p{
            margin: 0px;
            float:right;
        }
    </style>
</head>
<body>
    <ul>
        <li>
            <a href="#">左边</a>
            <p>右边</p>
        </li>
        <li>
            <a href="#">左边</a>
            <p>右边</p>
        </li>
        <li>
            <a href="#">左边</a>
            <p>右边</p>
        </li>
    </ul>
</body>
</html>

效果如下:

技术分享

解决方案:给li元素加上*vertical-align: top;属性

li{
            height: 30px;
            line-height: 30px;
            border:1px solid red;
            *vertical-align: top;
}

 

兼容性—IE6/7下当li里面的元素都浮动,li之间会产生4px的缝隙

原文:http://www.cnblogs.com/halai/p/6853174.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!