How can i hide certain table column in a HTML table using CSS

前端 未结 7 1695
长发绾君心
长发绾君心 2021-01-26 18:05

I have a html table which is as follows

col1 c
7条回答
  •  情书的邮戳
    2021-01-26 18:47

    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; /* Safari/Chrome, other WebKit */
        -moz-box-sizing: border-box;    /* Firefox, other Gecko */
        box-sizing: border-box;         /* Opera/IE 8+ */
    }
    
    table tr td:nth-child(n+4){
        display: none;
    }
    

提交回复
热议问题