html – 使用CSS保持浮动图像在div内

前端之家收集整理的这篇文章主要介绍了html – 使用CSS保持浮动图像在div内前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_301_0@
我遇到这个问题,与以往一样,但从来没有试图找到正确的解决方

码:

<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中?照片下方有分隔线

解决方法

更传统的方式(除了清除)是将包含div的overflow属性设置为hidden。
<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黑客。

原文链接:https://www.f2er.com/html/232747.html

猜你在找的HTML相关文章