Using CSS how to change only the 2nd column of a table

后端 未结 5 1333
悲&欢浪女
悲&欢浪女 2021-01-30 00:20

Using css only, how can I override the css of only the 2nd column of a table.

I can get to all of the columns using:

.countTable table table td
<         


        
5条回答
  •  终归单人心
    2021-01-30 01:05

    To change only the second column of a table use the following:

    General Case:

    table td + td{  /* this will go to the 2nd column of a table directly */
    
    background:red
    
    }
    

    Your case:

    .countTable table table td + td{ 
    
    background: red
    
    }
    

    Note: this works for all browsers (Modern and old ones) that's why I added my answer to an old question

提交回复
热议问题