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

后端 未结 7 2222

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

my text
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 15:01

    Use CSS nth-child with the prefix class name

    div.myclass:nth-child(1) {
      color: #000;
    }
    
    div.myclass:nth-child(2) {
      color: #FFF;
    }
    
    div.myclass:nth-child(3) {
      color: #006;
    }
    

提交回复
热议问题