반응형
아주 가끔씩 쓰게되서 찾게되는
css 선택자로 요소 1개 체크하는 방법...
:fisrt-child:last-of-child(1)
코드 예시
<div class="btns">
<button type="button">버튼 1</button>
<button type="button">버튼 2</button>
</div>
<div class="btns">
<button type="button">버튼 1</button>
</div>
<style>
.btns button:first-child{
border-radius: 20px 0 0 20px;
}
.btns button:last-child{
border-radius: 0 20px 20px 0;
}
.btns button:first-child:nth-last-child(1){
border-radius: 20px;
}
</style>

728x90
반응형
'웹 > CSS' 카테고리의 다른 글
| 애플뮤직에서 사용하는 CSS (1) | 2025.08.05 |
|---|---|
| CDN을 이용한 "pretendard variable" 웹폰트 적용 (성능 최적화 버전) (0) | 2025.04.18 |
| 웹폰트 사용 시 @import와 <link> 방식 중 어떤 걸 써야할까? (0) | 2025.04.18 |
| [css] & nesting 선택자 (0) | 2025.02.13 |
| 갤럭시 폴드의 실제 가로 해상도는 345px (0) | 2024.01.29 |
| 마우스 커서를 이미지로 변경하기 (0) | 2023.09.22 |
| [CSS] ":nth-child()"로 몇 번부터 몇 번까지 선택하기 (0) | 2023.08.21 |
| [css] 텍스트 안에 그라데이션 배경 움직여보기 (0) | 2023.06.08 |
댓글