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

后端 未结 7 2239

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

my text
7条回答
  •  清歌不尽
    2020-11-27 15:09

    use nth-child(item number) EX

    my text1
    some other code+containers...
    my text2
    some other code+containers...
    my text3
    some other code+containers...
    .parent_class:nth-child(1) { }; .parent_class:nth-child(2) { }; .parent_class:nth-child(3) { };

    OR

    :nth-of-type(item number) same your code

    .myclass:nth-of-type(1) { };
    .myclass:nth-of-type(2) { };
    .myclass:nth-of-type(3) { };
    

提交回复
热议问题