如何使表格单元格根据内容扩展

Tin*_*ger 3 html css

我想在桌子旁边放 3 个 div。表格应该根据里面的内容进行扩展,并且 3 个 div 应该平均占据剩余的空闲空间。

我需要将 div 堆叠在移动视图上的桌子下方,如下所示......

Desktop:
[div-1] [div-2] [div-3] [table]

Mobile:
[table]
[div-1]
[div-2]
[div-3]
Run Code Online (Sandbox Code Playgroud)

我一直在尝试使用 Flex 来使其正常工作,但我无法使表格根据内部内容进行扩展。

我无法使用,td {white-space: nowrap;}因为在移动设备上它将文本推出屏幕一侧。我需要表格根据内部内容进行扩展,但不应将内容强制扩展到屏幕之外。它需要像平常一样在较小的屏幕上环绕。

这是我的工作示例:http://codepen.io/anon/pen/qadbkK ?editors=1100

Desktop:
[div-1] [div-2] [div-3] [table]

Mobile:
[table]
[div-1]
[div-2]
[div-3]
Run Code Online (Sandbox Code Playgroud)
/* 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;
  }
}
Run Code Online (Sandbox Code Playgroud)

z0m*_*Bi3 5

设置white-space: nowraptd以便将整个文本放在一行中。

/* 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;
  }
}

td{
  white-space: nowrap;
}
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)