How to select first and last TD in a row?

前端 未结 5 1420
谎友^
谎友^ 2020-11-30 23:01

How can you select the first and the last TD in a row?

tr > td[0],
tr > td[-1] {
/* styles */
}
5条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 23:03

    If you use sass(scss) you can use the following snippet:

    tr > td{
       /* styles for all td*/
       &:first-child{
         /* styles for first */ 
       }
       &:last-child{
        /* styles for last*/
       }
     }
    

提交回复
热议问题