图像在文本上重叠

时间:2014-05-08 06:48:10

标签: css

代码:

第一个div包含图像,图像与第二个div的内容重叠。

   <div>
    <img src="happy.jpg" style="height:50px;width:50px;border-radius:50%;float:left" /> alex is desperately looking for college and there are many more like here
    </div>

    <div id="progressbar">
    <label id="ProgressText">
        alex is still unhappy, step <label id="RemainingSteps">2</label> to go
    </label>
    <div id="progressFilled">

    </div>
</div>

enter image description here

我希望该图像不应与第二个div的内容重叠。我怎么能这样做?

2 个答案:

答案 0 :(得分:1)

您需要将overflow设置为hidden。

<强> CSS

.wrap{
    overflow: hidden;
}

<强> HTML

<div class="wrap">
    <img src="happy.jpg" style="height:50px;width:50px;border-radius:50%;float:left" />
    alex is desperately looking for college and there are many more like here
</div>

<div id="progressbar">
    <label id="ProgressText">
        alex is still unhappy, step <label id="RemainingSteps">2</label> to go
    </label>
    <div id="progressFilled">
    </div>
</div>

答案 1 :(得分:0)

使用以下代码。

<div class="clearfix">
    <img src="happy.jpg" style="height:50px;width:50px;border-radius:50%;float:left" /> alex is desperately looking for college and there are many more like here
    </div>

    <div id="progressbar">
    <label id="ProgressText">
        alex is still unhappy, step <label id="RemainingSteps">2</label> to go
    </label>
    <div id="progressFilled">

    </div>
</div>

将此添加到CSS

.clearfix:after {
  content: "";
  display: table;
  clear: both;
}