简体   繁体   English

使用Bootstrap 4 d-md-inline折叠表

[英]Table collapses with Bootstrap 4 d-md-inline

I have the following HTML table: 我有以下HTML表:

 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <table class="w-100"> <thead> <tr> <td>Heading 1</td> <td>Heading 2</td> <td>Heading 3</td> </tr> </thead> <tbody> <tr> <td>Item 1</td> <td>Item 2</td> <td>Item 3</td> </tr> </tbody> </table> 

This displays properly and stretches across the page (ie, container). 这将正确显示并延伸到页面(即容器)。

If I add d-none d-md-inline to the <table> tag, the table collapses. 如果我将d-none d-md-inline<table>标记中,则表将折叠。 I've also tried d-md-inline-block and d-md-block but neither works. 我也尝试了d-md-inline-blockd-md-block但是都没有用。

 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <table class="w-100 d-none d-md-inline"> <thead> <tr> <td>Heading 1</td> <td>Heading 2</td> <td>Heading 3</td> </tr> </thead> <tbody> <tr> <td>Item 1</td> <td>Item 2</td> <td>Item 3</td> </tr> </tbody> </table> 

THE POINT: I want a table to display when on a MD screen or larger, and I want the big table to disappear when on a SM or XS screen (ie, mobile). 要点:我希望在MD屏幕或更大屏幕上显示表格,而在SM或XS屏幕(即移动设备)上时希望大桌子消失。 It functions correctly when moving the width of the window and when it hits the SM breakpoint, it disappears. 当移动窗口的宽度并碰到SM断点时,它会正确运行,然后消失。 The problem is that the table is collapsed onto itself and does not stretch (like justified) across the container width. 问题在于表格已折叠到其自身上,并且不会在容器宽度上伸展(如合理)。

How do I get the table to display properly in MD and bigger but disappear on SM and XS? 如何使表格在MD和更大的尺寸上正确显示,但在SM和XS上消失?

FIND THE CODE AT JSFIDDLE 在JSFIDDLE查找代码

https://jsfiddle.net/jallenmorris/m5ct40wd/10/ https://jsfiddle.net/jallenmorris/m5ct40wd/10/

Add one wrapper on a table like & add this class d-none d-md-block for wrapper div 在像这样的table上添加一个wrapper并为wrapper div添加此类d-none d-md-block

<div class="d-none d-md-block">
  <table class="table">
    <thead>
      <tr>
        <th>Heading 1</th>
        <th>Heading 2</th>
        <th>Heading 3</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Item 1</td>
        <td>Item 2</td>
        <td>Item 3</td>
      </tr>
    </tbody>
  </table>
</div>

https://jsfiddle.net/lalji1051/sdq03co9/4/ https://jsfiddle.net/lalji1051/sdq03co9/4/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM