html – 使用Bootstrap 3如何隐藏表格中的列?

前端之家收集整理的这篇文章主要介绍了html – 使用Bootstrap 3如何隐藏表格中的列?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在col-xs和col-sm中,我正试图为响应式设计隐藏列。我首先尝试使用hidden-xs / hidden-sm类,但这不起作用。我也试过使用这里提到的可见桌面: Twitter Bootstrap Responsive – Show Table Column only on Desktop

这也行不通。做这个的最好方式是什么?我宁愿不做两个单独的表然后隐藏其中一个。

我尝试过的代码目前无效:

<table>
    <thead>
        <th>Show All the time</th>
        <th class="hidden-xs hidden-sm">Hide in XS and SM</th>
    </thead>
    <tbody>
        <tr>
            <td>Show All the time</td>
            <td class="hidden-xs hidden-sm">Hide in XS and SM</td>
        </tr>
    </tbody>
</table>

解决方法

代码应该可以正常工作。 Bootstrap支持使用其响应实用程序类 https://github.com/twbs/bootstrap/blob/master/less/mixins.less#L504隐藏/显示th和td:
// Responsive utilities
// -------------------------
// More easily include all the states for responsive-utilities.less.
.responsive-visibility() {
  display: block !important;
  tr& { display: table-row !important; }
  th&,td& { display: table-cell !important; }
}

.responsive-invisibility() {
  display: none !important;
  tr& { display: none !important; }
  th&,td& { display: none !important; }
}

代码适用于此jsFiddle:http://jsfiddle.net/A4fQP/

原文链接:https://www.f2er.com/html/232599.html

猜你在找的HTML相关文章