【发布时间】:2020-09-17 11:16:43
【问题描述】:
我有这个代码
<table class="table table-bordered text-center font-weight-bold">
<tr>
<?php
for ($i = 1; $i <= 60; $i++) { ?>
<td class="<?= $i == 7 || $i == 8 || $i == 11 ? 'bg-danger' : 'bg-success'; ?> m-0 p-0">
<a href="#" style="text-decoration: none; font-size: 5vw">
<div class="h-100 w-100 my-2 text-white">
<?= $i; ?>
</div>
</a>
</td>
<?php if (!empty($i) && ($i) % 6 == 0) {
?>
</tr>
<tr>
<?php } ?>
<?php }
?>
</tr>
</table>
我想要这样的结果
1 2 3 4 5 6
12 11 10 9 8 7
13 14 15 16 17 18
24 23 22 21 20 19
25 26 27 28 29 30
36 35 34 33 32 31
37 38 39 40 41 42
等等……
我不知道最简单的逻辑是如何工作的
【问题讨论】:
-
如果你使用flexbox而不是表格,你可以按照你当前输出的顺序输出数据,然后使用CSS改变每隔一行的
flex-direction。
标签: php loops for-loop numbers