-
[CSS] 요소 개수별로 속성 적용HTML & CSS 2018. 11. 21. 16:08
//개수에 따른 속성 적용
.menu-list {
a:nth-child(1):nth-last-child(1),
a:nth-child(1):nth-last-child(1) ~ a {
width: 100%;
}
a:nth-child(1):nth-last-child(2),
a:nth-child(1):nth-last-child(2) ~ a {
width: 50%;
}
a:nth-child(1):nth-last-child(3),
a:nth-child(1):nth-last-child(3) ~ a {
width: 33.333%;
}
a:nth-child(1):nth-last-child(4),
a:nth-child(1):nth-last-child(4) ~ a {
width: 25%;
}
a:nth-child(1):nth-last-child(5),
a:nth-child(1):nth-last-child(5) ~ a {
width: 20%;
}
}//sass for문 사용
@for $i from 1 through 5 {
.개수에_따른_속성 {
a:nth-child(1):nth-last-child(#{$i}),
a:nth-child(1):nth-last-child(#{$i}) ~ a {
width: 100% / $i;
}
}
}'HTML & CSS' 카테고리의 다른 글
[CSS] input placeholder color (0) 2018.11.21 [CSS] 레이어 중앙 정렬 (ie7 ~) (0) 2018.11.21 [CSS] counter 사용 (0) 2018.11.21 [SASS] for문 활용 (0) 2018.11.21 [SASS] 자주 쓰는 @mixin 믹스인 (0) 2018.11.21 댓글