순환 css의 가장 간단한 방법: scss를 통해 n번째 하위 위조 클래스를 순환합니다

SCS를 통해 위류를 순환할 수 있는 두 가지 방법이 있지만 while 순환은 이를 더욱 쉽게 이해하고 처리할 수 있다.
$count: 1;
@while $count < 10+1{
  .classname:nth-of-type(#{$count}){
    width: auto;
  }
    $count: $count+1
}

이 출력은 다음과 같습니다.

.classname:nth-of-type(1) {
  width: auto;
}

.classname:nth-of-type(2) {
  width: auto;
}

.classname:nth-of-type(3) {
  width: auto;
}

.classname:nth-of-type(4) {
  width: auto;
}

.classname:nth-of-type(5) {
  width: auto;
}

.classname:nth-of-type(6) {
  width: auto;
}

.classname:nth-of-type(7) {
  width: auto;
}

.classname:nth-of-type(8) {
  width: auto;
}

.classname:nth-of-type(9) {
  width: auto;
}

.classname:nth-of-type(10) {
  width: auto;
}
고맙습니다.

좋은 웹페이지 즐겨찾기