저는 CSS가 새로 도입되었습니다.
각 구석의 스타일을 변경하기 위해 4 클래스를 만듭니다. 코드 분할 코드를 실행하는 과정에서 볼 수있는 것처럼 작동하지만 많은 코드가 반복됩니다.이 CSS를 단순화하는 방법
이것은 단지 다른 회선을
경계 폭 : 0 16px 16px 0;
나는 내가
<div id="infoPopup" class="note topRight">
내가 작업을 이미 가지고 무엇
.note {}
.note:before {}
.note:before .topLeft {border-width: 0 16px 16px 0;}
.note:before .topRight {border-width: 0 0 16px 16px;}
.note:before .bottomLeft {border-width: 16px 16px 0 0;}
.note:before .bottomRight {border-width: 16px 0 0 16px;}
같은 것을 시도하고 있었다 같은 것을 만들 수있는 CSS를 수정하고 싶은
.noteTopRight {
position: relative;
width: 30%;
padding: 1em 1.5em;
margin: 2em auto;
color: #fff;
background: #97C02F;
}
.noteTopRight:before {
content: "";
position: absolute;
top: 0;
right: 0;
border-width: 0 16px 16px 0;
border-style: solid;
border-color: #658E15 #fff;
}
.noteTopLeft {
position: relative;
width: 30%;
padding: 1em 1.5em;
margin: 2em auto;
color: #fff;
background: #97C02F;
}
.noteTopLeft:before {
content: "";
position: absolute;
top: 0;
left: 0;
border-width: 0 0 16px 16px;
border-style: solid;
border-color: #658E15 #fff;
}
.noteBottomRight {
position: relative;
width: 30%;
padding: 1em 1.5em;
margin: 2em auto;
color: #fff;
background: #97C02F;
}
.noteBottomRight:before {
content: "";
position: absolute;
bottom: 0;
right: 0;
border-width: 16px 16px 0 0;
border-style: solid;
border-color: #658E15 #fff;
}
.noteBottomLeft {
position: relative;
width: 30%;
padding: 1em 1.5em;
margin: 2em auto;
color: #fff;
background: #97C02F;
}
.noteBottomLeft:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
border-width: 16px 0 0 16px;
border-style: solid;
border-color: #658E15 #fff;
}
<div class="noteTopRight"><div>Hola<br> World</div></div>
<div class="noteTopLeft"><div>Hola<br> World</div></div>
<div class="noteBottomRight"><div>Hola<br> World</div></div>
<div class="noteBottomLeft"><div>Hola<br> World</div></div>
우선 첫 번째 : 'id'는 고유해야하므로 수정할 필요가 있습니다. 그런 다음 클래스를 결합 할 수 있도록 모든 div가 기본 클래스'.note'가 될 수 있으며 각 클래스에는 보조 클래스가 있습니다 (예 :'.note-top-right' 또는'.note-top-left ') - 공통 속성을'.note' 클래스로 옮기고 다른 값을 다른 네 클래스 각각으로 옮깁니다. 좀 더 자세한 정보가 필요하면 알려주세요 – ochi
@ochi 제가 하위 클래스와 비슷한 것을 볼 수 있습니다. 그러나': 전에 '는 나를 혼란스럽게 만들었다. 하위 클래스에서 해당 부분을 제거해야합니까? –
ID로 불편을 끼쳐 드려 죄송합니다. 각 클래스가 제대로 작동하는지 확인하기 위해 복사/붙여 넣기 작업을했습니다 :) –