How to obtain a grid of equal height list items?(如何获得等高列表项的网格?)
问题描述
我正在尝试使用列表项和 inline-block
制作产品网格.问题是:块的内容具有可变高度,而 inline-block
不保持高度相等.
I am trying to do a grid of products using list items and inline-block
. The problem is: the content of the blocks have variable heights and the inline-block
doesn't keep the heights equal.
代码:
#blocks ul{
list-style-type:none;
margin:0px;
padding:0px;
}
#blocks li {
display:inline-block;
vertical-align:top;
width:280px;
background-color:#ff9933;
padding:13px;
margin: 0px 0px 20px 19px;
}
<div id="blocks">
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</div>
这里有一张图片来说明问题.
我需要这些块与较大的块保持相同的高度,而与其内容无关.是否可以制作像 this 这样的东西?
I need the blocks to keep the same height of the larger blocks, independently of its content. Is it possible to make someting like this?
最后:抱歉,英语不是我的母语 :)
推荐答案
1. 将以下内容添加到 li
CSS 将模仿您提供的图像示例.
1. Adding the following to the li
CSS will mimic the image example you provided.
height: 150px;
min-height: 150px;
overflow:auto;
2.此外,还有一些其他方法:
2. Also, here are some other approaches:
- http://demo.smartnetzone.com/same-height-columns-使用-jquery/
- http://buildinternet.com/2009/07/four-methods-to-create-equal-height-columns/
- http://www.cssnewbie.com/equalheights-jquery-plugin/
这篇关于如何获得等高列表项的网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何获得等高列表项的网格?


基础教程推荐
- 检查 HTML5 拖放文件类型 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01