How to select the first, second, or third element with a given class name?

后端 未结 7 2229

How can I select a certain element in a list of elements? I have the following:

my text
7条回答
  •  再見小時候
    2020-11-27 14:52

    Yes, you can do this. For example, to style the td tags that make up the different columns of a table you could do something like this:

    table.myClass tr > td:first-child /* First column */
    {
      /* some style here */
    }
    table.myClass tr > td:first-child+td /* Second column */
    {
      /* some style here */
    }
    table.myClass tr > td:first-child+td+td /* Third column */
    {
      /* some style here */
    }
    

提交回复
热议问题