【发布时间】:2018-07-01 06:41:19
【问题描述】:
我目前正在尝试将一些来自数据库的类别显示到表格中。但我希望以这种方式显示类别:
Animals | Other | Other --> reached end of DIV,
Restaurants | Other | Other --> the info must continue in another
Houses | Other | Other --> line
------------------------------------------------------
Other |
Other |
所以我的逻辑是让变量计数$rows & $cols..但这不适用于每种屏幕尺寸..所以我需要更好的方法。
以下代码只是逻辑示例。
$categories = $all_categories();
$rows = 0;
$cols = 0;
$output = "<div><table>";
for($i = 0; $i <= count($categories) - 1; $i++){
$output .= "<tr><td>" . $categories[$i]['name'] . "</td></tr>";
}
$output .= "</table></div>";
echo $output;
表是否可以检测到它没有更多空间并在下一行继续<td>?
这里也是 jsfiddle:http://jsfiddle.net/G3fUw/
编辑:已解决,只需要更改这两行即可。
<tr style='display: inline-block'>
<td style='display: inline-block'>
【问题讨论】:
标签: php html-table