CSS of specific table row

后端 未结 3 1445
旧时难觅i
旧时难觅i 2021-01-16 05:33

I have a table as this one:

<         
相关标签:
3条回答
  • 2021-01-16 06:15

    Here is the Solution.

    The HTML:

    <table id="someID">
        <tr><td>example text</td></tr>
        <tr><td>example text</td><td>example text</td></tr>
        <tr><td>example text</td></tr>
        <tr><td>example text</td><td>example text</td></tr>
    </table>
    

    The CSS:

    table tr:nth-child(2) {display : none;}
    table tr:nth-child(3) {display : none;}
    

    You have to use :nth-child() to hide the rows that you desire.

    As most of the :nth-child() will not work for older browsers, here is the Solution for them.

    The HTML:

    <table id="someID">
        <tr><td>example text</td></tr>
        <tr><td>example text</td><td>example text</td></tr>
        <tr><td>example text</td></tr>
        <tr><td>example text</td><td>example text</td></tr>
    </table>
    

    The CSS:

    table tr:FIRST-CHILD + tr {
        display:none;
    }
    
    table tr:FIRST-CHILD + tr + tr {
        display:none;
    }
    

    Hope this helps now.

    0 讨论(0)
  • 2021-01-16 06:28

    You can do it using CSS3 CSS

    #someID tr:nth-child(2){display:none;}
    #someID tr:nth-child(3){display:none;}
    
    0 讨论(0)
  • 2021-01-16 06:34

    You can use :nth-child() selector:

    http://www.w3schools.com/cssref/sel_nth-child.asp

    0 讨论(0)
提交回复
热议问题
example text
example text