【发布时间】:2011-09-08 08:39:19
【问题描述】:
[编辑]感谢herkulano 和GerManson,他们的修复对我有用。
但我无法决定哪个更好、更可靠且跨浏览器兼容? “溢出”或“clearfix:?请帮我解决这个问题,我很高兴。
如果我的问题不清楚,现在就可以了。请继续阅读...
(我正在尝试在 php 中显示一些缩略图,这些是我正在使用的相应代码。)
1. 以下是我正在使用的 CSS 代码:
#gallerythumbnailsx { margin: 10px; }
#gallerythumbnailsx .gallery-item { float: left; margin-top: 10px; text-align: center; }
#gallerythumbnailsx img { border: 2px solid #cfcfcf; margin-left: 5px; }
#gallerythumbnailsx .gallery-caption { margin-left: 0; }
2.使用的相关php代码为:
<div id="gallerythumbnailsx"><?php echo show_all_thumbs(); ?></div>
<p>Aahan is great!</p>
3.这是生成的 HTML 的显示方式:
<div id="gallerythumbnailsx">
<dl class="gallery-item">
<dt class="gallery-icon">
<a href="http://example.com/"><img width="100" height="75" src="http://example.com/xxx.jpg"></a>
</dt>
</dl>
<dl class="gallery-item">
<dt class="gallery-icon">
<a href="http://example.com/"><img width="100" height="75" src="http://example.com/xxx1.jpg"></a>
</dt>
</dl>
<dl class="gallery-item">
<dt class="gallery-icon">
<a href="http://example.com/"><img width="100" height="75" src="http://example.com/xxx3.jpg"></a>
</dt>
</dl>
</div>
不幸的是,这就是它的显示方式 (screenshot)。如您所见,问题在于文本“Aahan 很棒!”因为我在 CSS 中使用 float: left 来表示缩略图,所以被推到缩略图的右侧。我希望文本换行。
【问题讨论】: