加入收藏 | 设为首页 | 会员中心 | 我要投稿 焦作站长网 (https://www.0391zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 系统 > 正文

IE6和IE7中行内元素后的浮动元素被折行的问题解决

发布时间:2020-03-13 21:18:54 所属栏目:系统 来源:站长网
导读:这篇文章主要介绍了IE6和IE7中行内元素相邻的浮动元素被折行的问题解决,包括在IE8中,会把浮动元素的当前行认为是前面非浮动元素的框的底边,从而导致问题,这里我

XML/HTML Code复制内容到剪贴板

<ul class="list">  

 <li><a href="#" title="">新闻一Benjamin</a><span>2014-05-06</span></li>  

 <li><a href="#" title="">新闻一Benjamin</a><span>2014-05-06</span></li>  

 <li><a href="#" title="">新闻一Benjamin</a><span>2014-05-06</span></li>  

 <li><a href="#" title="">新闻一Benjamin</a><span>2014-05-06</span></li>  

</ul>  

CSS Code复制内容到剪贴板

<style type="text/css">   

 body,ul{padding:0;margin:0;}   

 ul{list-style-typenone;border:1px solid #ccc;}   

 li{padding-left:0;}   

 .list{width:300px;margin:100px auto;}   

 .list li{height:24px;line-height24px;border-bottom1px solid #ccc;margin-bottom:-1px;padding-left10px;}   

 .list li span{float:rightright;margin-right:10px;}   

 .list li .float_a{float:left;}   

 .fix {*zoom:1;}   

 .fix:after {displayblockcontent".";visibilityhidden;clearboth;height: 0;overflowhidden;}   

</style>  

二、各浏览器效果图

2016627120709205.gif (310×540)

三、原因分析
1.标准参考:
W3C CSS2.1规范文档里对于浮动元素与非浮动行内元素相邻时的情况有如下解释。以下是关键段落:
A floated box is shifted to the left or right until its outer edge touches the containing block edge or the outer edge of another float. If there’s a line box, the top of the floated box is aligned with the top of the current line box.
由上面的描述可以得到以下结论:如果一个元素浮动前是一个行内元素,则该元素浮动后,顶部应与其之前所在的行框顶部对齐。
2.问题描述:
IE6 IE7 IE8(Quick)下,若浮动元素之前存在兄弟行内非浮动元素,IE 会将浮动元素所在的“当前行”认为是其前边的兄弟行内元素所产生的匿名框的底边,导致该浮动元素折行。

四、解决方案
1.全浮动

CSS Code复制内容到剪贴板

<ul class="list">   

(编辑:焦作站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读