我想要创建的是从我的数据库中获取结果并使用 CSS 将它们显示为这样的两列的页面(除非有更好的方法)......
Row 1 | Row 6
Row 2 | Row 7
Row 3 | Row 8
Row 4 | Row 9
Row 5 | Row 10
如果不超过 5 行,则第二列应为空。
因此,如果您的目标是拥有一个包含两列的列表,那么在 CSS 中没有标准的方法可以做到这一点。CSS3 提供的一种方法(但大多数浏览器不支持)是columns
属性,但是关于这个规则的不好的部分(我上次检查的时候)是它迫使你预先选择你想要的列数并且你可以' t 指定“最大列”的概念。
但我发现最好的解决方法是在A List Apart:
但如果您只想要多列数据,最好的解决方案是使用 HTML 表格。
如果第 1 列的行数固定
CSS:
.leftcolumn
{
Float:left;
}
.other
{
display:none;
}
html
<div class="leftcolumn">
return some rows here
</div>
<div class="<? other ?>">
return more rows here
</div>
php 或任何语言
if
[select count(*) from table where foo=bar DESC limit 20,0] >5
other = "other"
else
other = "leftcolumn"