mirror of
https://github.com/muerwre/muerwre.github.io.git
synced 2025-04-25 02:46:39 +07:00
added whole content
This commit is contained in:
parent
1b5df685cb
commit
8b25e0631a
70 changed files with 5962 additions and 19 deletions
19
content/CSS/Sass nth-child iterate mixin.md
Normal file
19
content/CSS/Sass nth-child iterate mixin.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
Say, we need to color `n` items by specific colors, which depend on its position. #SCSS supports [iteration over lists](https://sass-lang.com/documentation/at-rules/control/each) for that purposes:
|
||||
|
||||
```scss
|
||||
@mixin color-per-child($colors) {
|
||||
@each $color in $colors {
|
||||
&:nth-child(#{index(($colors), ($color))}) {
|
||||
color: $color;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Usage is simple:
|
||||
|
||||
```scss
|
||||
.item {
|
||||
@include color_per_child((#ded187, #dbde87, #bade87, #9cde87, #87deaa));
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue