使一行中的列表项的高度遵循其最大高度
在此页面中: http://pastehtml.com/view/1biylhs.html
你可以在中间看到这本书比同一行的其他两本书需要更多的高度空间,因为它的标题有更多的文字。
目前,每本书都包含在
中,高度为 175px。我可以将它们的高度设置为自动,但它仍然无法使同一行中的所有列表项遵循其中最大的高度:
http://pastehtml.com/view/1bj19w3.html
使每行中的列表项遵循该行中这些列表项的最大高度的最简单方法是什么?我必须让它在 IE6 中也能工作。
非常感谢大家。
In this page:
http://pastehtml.com/view/1biylhs.html
You can see the book in the center needs more height space than the other two books in the same row because its title has more text.
Currently, each book is contained in a <li>
and has a height of 175px.
I can set their height to auto but it still can't make all list items in the same row follow the largest height among them:
http://pastehtml.com/view/1bj19w3.html
What is the simplest way to make the list items in each row follow the largest height of those list items in that row? I have to make it work in IE6 as well.
Many thanks to you all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议添加一些额外的标记。也许让它成为一个列表的列表。
像这样
然后一些CSS沿着
.row{
清除:左;
浮动:左;
最小高度:175px;
注意
允许高度扩展的最小高度。您需要将高度输入 IE6 才能达到相同的效果。为此,您有很多选择。 条件注释是符合标准的选择之一。
最后,请注意,我使用 h2 而不是 div 来包含书名。您可能想给标题赋予一定的语义权重,以使它们在搜索中脱颖而出,因此 h2(或任何标题元素)是比 div 更好的容器。
I suggest adding some additional markup. Make it a list of lists perhaps.
Something like this
Then some CSS along the lines of
.row{
clear:left;
float:left;
min-height:175px;
}
Note the min-height which allows the height to expand. You will need to feed height to IE6 to achieve the same effect. To do that, you have a lot of options. Conditional comments are one of the standards-compliant choices.
Finally, note that I have used h2 instead of div to contain the book titles. You probably want to give the titles a bit of semantic weight to make them stand out to searches, and so h2 (or any header element) is a better container than div.
我用 Javascript 处理它:
这有点生硬,你可以使用 jquery 这样的框架获得更优雅的代码,但这对我来说很有效,跨浏览器和平台。
编辑:
这是针对 HTML 代码格式化的:
I handle it with Javascript:
It's a little blunt, you can get more elegant code using a framework like jquery but this has worked for me, cross browser and platform.
Edit:
This is for HTML code formatted thus:
这绝对是不容易做到的。您谈论行,但浏览器看不到行,它只是看到包裹的浮动。
你可以选择表格(不是因为它是表格,而是因为没有任何表格布局就很难做到),但我不会那么快放弃。
作为妥协,我建议让每个浮动块足够高以容纳图像和大约三行文本。然后他们每个人都有相同的高度并且排列得很好这仍然是一个猜测,但可能是你能做到的最好的。 。
This is definitely not easy to do. You talk about rows, but the browser is not seeing rows, it's just seeing wrapped floats.
You could go for tables (not because it's tabular, but just because this layout is very difficult to do without any) but I wouldn't give up that quickly.
As a compromise, I would suggest making each floated block high enough for the image and about three lines of text. Then they each have the same height and line up nicely It's still a guess, but probably the best you can do. .