I have a html table which is as follows
col1 col2 Solution 1:
You can indeed do this:
http://jsfiddle.net/nEQ6g/1/
*EDIT - From my knowledge nth-child
and visability: hidden
don't play nice together. For what you want, you'd need to use display: none;
- based upon the code I've provided you.
CSS:
table {
border-collapse : collapse;
}
table tr td {
padding : 10px ;
border : 1px solid #ccc ;
-webkit-box-sizing : border-box;
-moz-box-sizing : border-box; box-sizing : border-box;
}
table tr td :nth-child (n+4 ){
display : none;
}
Copy Solution 2:
Use something like this...
CSS
td :nth-child (4 ), td :nth-child (5 ), td :nth-child (6 ), td :nth-child (7 )
{
display :none;
}
Copy Solution 3:
Solution 4:
You can use css3 nth child
selector, e.g.
td :nth-child (4 ),td :nth-child (5 ), ...
{
display :none;
}
Copy jsFiddle here
Solution 5:
I've got no idea what's the intent, the reason or the audience but if you append a data attribute to each column cell...
<td data-col ="1" > </td >
Copy You can then use jQuery to hide all cells that belong to a specific column...
$('td[data-col=1]' ).hide ();
Copy You could also use the ':nth-child ()' css pseudo class but it is not supported by some IE browsers
Hope it makes sense
Post a Comment for "How Can I Hide Certain Table Column In A Html Table Using Css"