我在<div>后面加了个<span>,为什么position:absolute和float:left显示效果不一样?
html代码均为:
<div class="container">
<a href="#" title="">进入课程请单击这里</a><span>文本1文本文本2文本3文本4文本5文本6文本7文本8文本9文本10</span>
</div>
第一个CSS代码为:
<style>
.container a{
position:absolute;/*文本跟在后面,被背景遮挡*/
width:200px;/*可以设的高度、宽度、行高、上下边距*/
background:#ccc;
}
</style>
第二个CSS代码为:
<style>
.container a{
float:left;/*文本跟在后面,没有被背景遮挡*/
width:200px;/*可以设的高度、宽度、行高、上下边距*/
background:#ccc;
}
</style>
position:absolute; 文本跟在后面,被背景遮挡
float:left; 文本跟在后面,没有被背景遮挡
求大神解释,为什么会出现这两种不同的情况呢?