-1

My SCSS looks like this:

.wrapper {
    .part {
        ...
        &.wheel {
            ... // code goes here
        }
     }
}

And my html looks like this:

<div class="wrapper">
    <img src="..." class="part wheel"/>
    <img src="..." class="part wheel"/>
</div>

How can I select first and second wheel using CSS? I want to give them different properties.

mdmb
  • 4,075
  • 3
  • 36
  • 79
  • 2
    have a look at `:nth-child` selector but beware as it is an element selector (rather than class) so if you have any other elements in between, it won't work – Pete Jun 22 '17 at 14:03
  • `&:nth-of-type(1) { ... }` and `&:nth-of-type(2) { ... }` – StudioTime Jun 22 '17 at 14:04

2 Answers2

1
.wheel:nth-of-type(1){...}
.wheel:nth-of-type(2){...}

or

.wheel:nth-child(1){...}
.wheel:nth-child(2){...}
mikepa88
  • 623
  • 6
  • 19
0

Use nth-of-type

.wrapper {
    .part {
        ...
        &.wheel {
            &:nth-of-type(1) { ... }
            &:nth-of-type(2) { ... }
        }
     }
}
StudioTime
  • 20,816
  • 34
  • 110
  • 202