[scss] @for (through / to)

홍싸리·2023년 5월 22일
0

@for through

@for $index from 1 through 3

  • through 숫자까지 반복
    * 1부터 3까지 반복
/* scss */
@for $index from 1 through 3 {
	.through:nth-of-type(#{$index}){
    	width: 20px * $index;
    }
}

/* css 변환 결과 */
.through:nth-of-type(1){width:20px}
.through:nth-of-type(2){width:40px}
.through:nth-of-type(3){width:60px}

@for to

@for $index from 1 to 3

  • to 바로 앞 숫자까지만 반복
    * 1부터 2까지 반복
/* scss */
@for $index to 1 to 3 {
	.to:nth-of-type(#{$index}){
    	width: 20px * $index;
    }
}

/* css 변환 결과 */
.to:nth-of-type(1){width:20px}
.to:nth-of-type(2){width:40px}
profile
그럴싸한건 다 따라해보는 프론트엔드 개발자 준비중인 6년차 퍼블리셔

0개의 댓글