5,006
社区成员
发帖
与我相关
我的任务
分享
<div style="border:1px solid black; font:14px Verdana; width:200px; padding:5px;">
The Lord of the Rings <span style="background:tomato; float:left;">*</span>
<br/>
<br/>
Gone with the wind <span style="background:tomato; float:left;">*</span>
</div>
可惜啊可惜,在 IE 里竟然不好用。看截图:<div style="border:1px solid black; font:14px Verdana; width:500px; padding:5px;">
<span style="background:gold;">Text1</span>
<span style="background:lightblue;">Text2</span>
<span style="background:pink;">Text3</span>
<span style="background:tomato; float:right;">Some text aligning right</span>
<span style="background:greenyellow;">Text4</span>
<span style="background:peru;">Text5</span>
</div>
以上例子中,右浮动框处于几个span元素之间,也就是说它前面含有行内元素。看几个浏览器测试的截图结果:<div style="border:1px solid black; font:14px Verdana; width:300px; padding:5px;">
<span style="background:gold;">Text1</span>
<span style="background:lightblue;">Text2</span>
<span style="background:pink;">Text3</span>
<span style="background:tomato; float:right;">Some text aligning right</span>
<span style="background:greenyellow;">Text4</span>
<span style="background:peru;">Text5</span>
</div>
这时,只看浮动元素的位置,各浏览器中表现相同(排除IE中盒子模型和浮动元素对高度影响的问题,IE会把外面的包含框给撑开):