我有一个包含 6 个元素的未定义列表。我想将这些元素组织成 2 列,左侧为奇数,右侧为偶数,无论元素内容高度如何。
基本上是 CSS:
ul li
{
list-style:none;
width:270px;
background:#eee;
margin-bottom:10px;
padding:10px;
display:inline;
}
ul li:nth-child(odd)
{
float:left;
}
ul li:nth-child(even)
{
float:right;
clear:right;
}
最佳答案
您可以简单地使用 display: inline-block
而无需 float
。只需将 LI 宽度设置为:50%。
关于html - 如何将 <li> 组织成列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25814544/