-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,833
  • 7
  • 42
  • 90
  • 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
  • 733
  • 1
  • 6
  • 20
0

Use nth-of-type

.wrapper {
    .part {
        ...
        &.wheel {
            &:nth-of-type(1) { ... }
            &:nth-of-type(2) { ... }
        }
     }
}
StudioTime
  • 22,603
  • 38
  • 120
  • 207