이것을 작성하는 좀 더 우아한 방법이 있습니까?동일한 속성 값을 가진 둘 이상의 요소에 대한 선택자가 있습니까?
.standard {
padding-top: 50px;
padding-bottom: 50px;
}
.standard.color-0 + .standard.color-0,
.standard.color-1 + .standard.color-1,
.standard.color-2 + .standard.color-2,
.standard.color-3 + .standard.color-3,
.standard.color-4 + .standard.color-4,
.standard.color-5 + .standard.color-5,
.standard.color-6 + .standard.color-6,
.standard.color-7 + .standard.color-7,
.standard.color-8 + .standard.color-8 {
padding-top: 0;
}
아마도 실제로 정확한 클래스의 이름을 모르는 상태에서 2 개 이상의 요소에있는 클래스의 일치를 확인 어떤 선택이 있습니까? 이러한 뭔가 등 :
나는 현재 (위 게시) 한 무엇.standard.color-* + .standard.color-* {
padding-top: 0;
}
나는 내 사이트에 표시하는 방법으로 지금까지 그것을 원하는 방식으로 작동하지만, 난 그냥 여부 호기심, 또는 아니다, 나는 운명입니다 내가 필요한 모든 새로운 색상에 대해 항상 .standard.color-# + .standard.color-#
을 추가하십시오 (이 경우에는 전체 폭이 <section>
태그 인 배경색 임).
예 :
<section class="standard color-0"></section> // top and bottom padding
<section class="standard color-1"></section> // top and bottom padding
-----------------------------------------------------------------------
<section class="standard color-1"></section> // top and bottom padding
<section class="standard color-1"></section> // padding-top: 0; (if both "color-#" is the exact same this loses its top padding)
편집 : 단순화 된 포스트 코드. <section>
은 항상 .standard
클래스이고 인 .color-
클래스는 background-color: transparent;
입니다.
할 방법이 없습니다. 아니요. – Ryan