使用CSS在div中保留浮动图像 [英] Keeping an floated image inside the div with CSS

查看:96
本文介绍了使用CSS在div中保留浮动图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到这个问题,与以往一样,但从不尝试找到正确的解决方案

I'm having this problem, same as ever, but never try to find the right solution

代码:

 <div id="ListOfTextAndPhotos">
      <div style="border-bottom: solid 1px silver;">
          <img src="photo.jpg" style="float: left">
          Some text about the photo
      </div>
      <div style="border-bottom: solid 1px silver;">
          <img src="photo2.jpg" style="float: left">
          Some text about the photo2
      </div>
      <div style="border-bottom: solid 1px silver;">
          <img src="photo3.jpg" style="float: left">
          Some text about the photo3
      </div>
  </div>

问题:
如何将照片保存在DIV? / strong>与照片下面的分隔线

Question: How do I to keep the photo inside the DIV? with the separator line under the photo

推荐答案

更传统的方式

<div style="border-bottom: solid 1px silver; overflow: hidden;">
      <img src="photo3.jpg" style="float: left">
      <div>Some text about the photo3</div>
</div>

有时,IE6不符合设置,您必须诉诸cLFlaVA hack。

Sometimes, IE6 does not honor the setting and you have to resort to the cLFlaVA hack.

这篇关于使用CSS在div中保留浮动图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆