【发布时间】:2017-01-14 22:33:36
【问题描述】:
我想在一张桌子旁边放 3 个 div。表格应该根据里面的内容展开,3个div应该平均占用剩余的空间。
我需要 div 像这样在移动视图的桌子下堆叠...
Desktop:
[div-1] [div-2] [div-3] [table]
Mobile:
[table]
[div-1]
[div-2]
[div-3]
我一直在玩弄 Flex 以使其正常工作,但我无法让表格根据里面的内容展开。
我不能使用td {white-space: nowrap;},因为在移动设备上它会将文本从屏幕一侧推出。我需要根据里面的内容来扩展表格,但内容不应该被强制到屏幕之外。它需要像平常一样在较小的屏幕上环绕。
这是我的工作示例:http://codepen.io/anon/pen/qadbkK?editors=1100
/* Do this on tablet size and up */
@media (min-width: 481px) {
/* Main outer div of helper items AND subtotals */
.cart-collaterals {
display: inline-flex;
}
/* Outer div of helper items */
.cart-helper-outer {
order: -1;
display: inline-flex;
justify-content: space-around;
}
/* Helper item width */
.cart-helper-inner {
max-width: 25%;
}
/* Helper item font */
.cart-helper-inner p {
text-align: center;
}
}
<div class="cart-collaterals">
<div class="cart_totals">
<table class="shop_table" cellspacing="0">
<tbody>
<tr class="cart-subtotal">
<th>Subtotal</th>
<td data-title="Subtotal">$ 348</td>
</tr>
<tr class="shipping">
<th>Shipping</th>
<td data-title="Shipping">
The table should expand so that this is one line of text
</td>
</tr>
<tr class="order-total">
<th>Total</th>
<td data-title="Total">$ 348</td>
</tr>
</tbody>
</table>
</div>
<div class="cart-helper-outer">
<div class="cart-helper-inner">
<p>This is some text. Blah blah blah. Here is some text.</p>
</div>
<div class="cart-helper-inner">
<p>This is some text. Blah blah blah. Here is some text.</p>
</div>
<div class="cart-helper-inner">
<p>This is some text. Blah blah blah. Here is some text.</p>
</div>
</div>
</div>
【问题讨论】: