【发布时间】:2020-06-30 21:11:25
【问题描述】:
我有一个简单的应用程序,它有一个包含四列的简单表格,我需要一个响应式表格,其中每一列都在另一列之下,但我不知道该怎么做。我希望不使用Javascript有一些答案。
现在我有一张这样的表:
+---------------+
| Some text |
+---------------+
| A | B | C | D |
+---+---+---+---+
| A | B | C | D |
+---+---+---+---+
| A | B | C | D |
+---+---+---+---+
| A | B | C | D |
+---+---+---+---+
我需要以更小的分辨率得到这个结果:
| A | B | C | D |
+---+---+-
| A | B |
+---+---+
| A | B |
+---+---+
| A | B |
+---+---+
| C | D |
+---+---+
| C | D |
+---+---+
| C | D |
+---+---+
等等。有可能吗?这是我的JSfiddle。 jsfiddle中的答案也是最好的。
这里是 HTML
<table>
<tbody>
<tr>
<td style="text-align: center; font-size: 14px;" colspan="4">Some title</td>
</tr>
<tr>
<td style="text-align: center; background-color: #e8e8e8;"> <span style="color: #1e2a64;"><strong>Title</strong></span>
</td>
<td style="text-align: center; background-color: #dedcdd;"><strong> <span style="color: #1e2a64;">Title2</span></strong>
</td>
<td style="text-align: center; background-color: #d5d3d4;"><strong> <span style="color: #1e2a64;">Title3</span></strong>
</td>
<td style="text-align: center; background-color: #e0f0cb;"><strong> <span style="color: #5ca402;">Title4</span></strong>
</td>
</tr>
<tr>
<td style="text-align: center; background-color: #f5f5f5;">
<div class="circle"><strong> 1.500</strong> <sup>eur</sup>
<br>month</div>
</td>
<td style="text-align: center; background-color: #efedee;">
<div class="circle"><strong>40.000</strong> <sup>eur</sup>
<br>month</div>
</td>
<td style="text-align: center; background-color: #e7e5e6;">
<div class="circle"><strong> 700</strong> <sup>eur</sup>
<br>month</div>
</td>
<td style="text-align: center; background-color: #f0fae2;">
<div class="circle-free">
<p class="hidden_paragraph">hidden</p>
<p style="padding-left: 10px;">0 <sup>eur</sup>
</p>
</div>
</td>
</tr>
<tr>
<td style="text-align: center; background-color: #f5f5f5;"> <strong>Text</strong>
<p></p>
<p><span style="color: #555555;">Lorem Ipsum</span>
</p>
<p><span style="color: #555555;">Lorem Ipsum</span>
</p>
<p><span style="color: #555555;">Lorem Ipsum</span>
</p>
</td>
<td style="text-align: center; background-color: #efedee;"> <strong>Text</strong>
<p></p>
<p><span style="color: #555555;">Lorem Ipsum</span>
</p>
<p><span style="color: #555555;"><del>Lorem Ipsum</del></span>
</p>
<p><span style="color: #555555;"><del>Lorem Ipsum</del></span>
</p>
</td>
<td style="text-align: center; background-color: #e7e5e6;"> <strong>Text</strong>
<p></p>
<p><span style="color: #555555;"><del>Lorem Ipsum</del></span>
</p>
<p><span style="color: #555555;"><del>Lorem Ipsum</del></span>
</p>
<p><span style="color: #555555;"><del>Lorem Ipsum</del></span>
</p>
</td>
<td style="text-align: center; background-color: #f0fae2;"> <strong>Text</strong>
<p></p>
<p><span style="color: #555555;"><del>Lorem Ipsum</del></span>
</p>
<p><span style="color: #555555;"><del>Lorem Ipsum</del></span>
</p>
<p><span style="color: #555555;"><del>Lorem Ipsum</del></span>
</p>
</td>
</tr>
<tr style="height: 70px;">
<td style="text-align: center; background-color: #f5f5f5; vertical-align: middle;">
<input id="kontakt_btn" type="button" value="contact">
</td>
<td style="text-align: center; background-color: #efedee; vertical-align: middle;">
<input id="kontakt_btn" type="button" value="contact">
</td>
<td style="text-align: center; background-color: #e7e5e6; vertical-align: middle;">
<input id="kontakt_btn" type="button" value="contact">
</td>
<td style="text-align: center; background-color: #f0fae2; vertical-align: middle;">
<input id="kontakt_btn" type="button" value="contact">
</td>
</tr>
</tbody>
</table>
CSS
@media all and (max-width:768px){
tr{
display: inline;
float:left;
}
td{
display: block;
}
}
注意:没有引导程序
【问题讨论】:
-
codepen 你提供的未找到,我不想只使用网格什么的 CSS
-
是的,css网格,只是css,不知道你的意思。对不起,链接是codepen.io/AllThingsSmitty/pen/MyqmdM
-
好的,我去看看