Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Bootstrap 3 how can I hide columns in my table?

I'm trying to hide columns for my responsive design when in col-xs and col-sm. I first attempted to use hidden-xs/hidden-sm classes, but this didn't work. I also tried using visible-desktop as mentioned here: Twitter Bootstrap Responsive - Show Table Column only on Desktop

That also didn't work. What is the best way to do this? I rather not make two separate tables and then hide one or the other.

Code I tried that's not currently working:

<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> 
like image 217
daveomcd Avatar asked Aug 21 '13 16:08

daveomcd


People also ask

How do I hide columns in a table?

To hide individual columns, open the table for which you are hiding a column, right-click the column, and click Hide from Client Tools. You can hide multiple columns at a time by holding down the Ctrl key or the Shift key.

How do I hide an entire column in CSS?

Usually, to hide an element from view, you use the 'display' property and set it to 'none'. But CSS also has a property called 'visibility', which hides elements in a different way. In particular, we use 'visibility: collapse' here, which is designed especially for hiding table columns and rows.


1 Answers

It seems hidden-xs/hidden-sm has worked before since the accepted answer has many up votes, however the fiddle example does not work for me when I'm resizing the area. What works for me though is opposite logic using visible-md/visible-lg. I can't understand why because according to documentation Bootstrap should still support hidden-xs/hidden-sm.

Working fiddle: http://jsfiddle.net/h1ep8b4f/

<table>     <thead>         <th>Show All the time</th>         <th class="visible-md visible-lg">Hide in XS and SM</th>     </thead>     <tbody>         <tr>             <td>Show All the time</td>             <td class="visible-md visible-lg">Hide in XS and SM</td>         </tr>     </tbody> </table> 
like image 155
Ogglas Avatar answered Sep 29 '22 04:09

Ogglas