전 세계에서 초보자입니다. LESS
에 월드 클래스를 구성하는 방법에 대한 질문이 있습니다.클래스를 올바르게 구성하는 방법
여기 내 수업은 less
입니다.
.links {
width: 9em;
height: 4em;
position: absolute;
top: 40%;
left: 50%;
margin-top: -20px;
margin-left: -45px;
opacity: 0;
-webkit-transform: translate(0,-50px);
-moz-transform: translate(0,-50px);
-ms-transform: translate(0,-50px);
-o-transform: translate(0,-50px);
transform: translate(0,-50px);
a {
i {
position: relative;
color: @colorMainGreen;
font-size: 16px;
margin: 0 13px;
z-index: 100;
&::after {
position: absolute;
content: "";
left: -7px;
top: -7px;
width: 30px;
height: 30px;
border: 1px solid @colorMainGreen;
z-index: -1;
border-radius: 3px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
&:hover i {
color: #fff;
}
}
&:hover {
i {
&:hover {
background-color: @colorMainGreen;
}
}
}
}
}
는 것을 분명히 여기에 컴파일 된 버전
.links {
width: 9em;
height: 4em;
position: absolute;
top: 40%;
left: 50%;
margin-top: -20px;
margin-left: -45px;
opacity: 0;
-webkit-transform: translate(0, -50px);
-moz-transform: translate(0, -50px);
-ms-transform: translate(0, -50px);
-o-transform: translate(0, -50px);
transform: translate(0, -50px);
}
.links a i {
position: relative;
color: #68c3a3;
font-size: 16px;
margin: 0 13px;
z-index: 100;
}
.links a i::after {
position: absolute;
content: "";
left: -7px;
top: -7px;
width: 30px;
height: 30px;
border: 1px solid #68c3a3;
z-index: -1;
border-radius: 3px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.links a i:hover i {
color: #fff;
}
.links a:hover i:hover {
background-color: #68c3a3;
}
를 만들려면 그리고 당신은
I을 볼 수 있듯이 나는이 부분이 내 적은 코드에
.links,
.links a i,
.links a i::after {
-webkit-transition: all 400ms;
-moz-transition: all 400ms;
-o-transition: all 400ms;
transition: all 400ms;
}
를 추가해야 이 클래스를 링크 및 자식 클래스에 적용해야합니다.
나는 모든 사용 가능한 방법을 모르고 있기 때문에 mixins를 사용하여 각 클래스에 추가하는 방법을 고려할 수 있습니다. 그러나 이것은 코드 중복입니다. 어쩌면 이것을 수행 할 또 다른 방법이 있습니다. 확장에 대해 읽었습니다. 아마 여기에서 사용할 수 있습니까? OOP 언어에서는 이러한 단순한 상속이 가능합니다. 이러한 코드를 구성하는 가장 좋은 방법을 제안하십시오.
감사합니다! 너 나 많이 도와 줬어! – ketazafor
솔직히 말해서, 이것은 내 개인 코드가 아니며 무료 템플릿 (유료 버전에서도 사용 가능)에서 사용합니다. – ketazafor