简体   繁体   English

使响应式引导表为水平

[英]Make responsive bootstrap table horizontal

I have a bootstrap table like 我有一个引导表

 <table class="table-responsive" >
    <th> Points </th>                                           
    <th> Players </th>                               
    <th> Prizes </th>

    <tr>
      <td>{{ points }}</td>              
      <td>{{ players }}</td>              
      <td>{{ prizes }}</td>                            
    </tr>

 </table>

and this table looks like 这个桌子看起来像

在此处输入图片说明

The problem is that it looks like this , even in small screens. 问题是,即使在小屏幕上,它看起来也是这样。 How can I make it horizontal in small screens, like the following image ? 如何在小屏幕上使其水平,如下图所示?

在此处输入图片说明

The desired structure of table on small screen could not be achieved using the original table as the structure is different. 使用原始表无法实现小屏幕上所需的表结构,因为结构不同。 So a hack of displaying an alternate table on the smaller screens and hiding the original table on the smaller screen and vice versa would be functional. 因此,可以在较小的屏幕上显示备用表,然后在较小的屏幕上隐藏原始表,反之亦然。

HTML 的HTML

<table id="big-screen">
    <tr>
        <th>Points</th>                                           
        <th>Players</th>                               
        <th>Prizes</th>
    </tr>
    <tr>
        <td>{{ points }}</td>              
        <td>{{ players }}</td>              
        <td>{{ prizes }}</td>                            
    </tr>
</table>
<table id="small-screen">
    <tr><th>Points</th></tr>
    <tr><td>{{ points }}</td></tr>                               
    <tr><th>Players</th></tr>
    <tr><td>{{ players }}</td></tr>
    <tr><th>Prizes</th></tr>
    <tr><td>{{ prizes }}</td></tr>
</table>

CSS 的CSS

@media screen and (max-width: 319px) {
  #small-screen {
    display: table;
  }
  #big-screen {
    display: none;
  }
}

@media screen and (min-width: 320px) {
  #small-screen {
    display: none;
  }
  #big-screen {
    display: table;
  }
}

Here is the jsfiddle 这是jsfiddle

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

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