$ 사용-- 사용:root {
--blue: #00f;
--primary-color: var(--blue);
}
(--green 속성이 없을 때 대안으로 #fff가 적용되도록 설정 > 폴백)
.text-card-1 {
color: var(--green, #fff);
}
지역 변수를 선언할 때 전역 변수 값을 할당할 수 있다
.container{
--text-color: var(--green);
}
--text-color을 재정의 했기 때문에 부모 값인 blue를 상속받음.container{
color: var(--text-color);
.parent {
--text-color: blue;
.child {
color: var(--text-color);
}
}
}
규칙 선언
@property --text-color {
syntax: '<color>';
inherits: false;
initial-value: orange;
}
-> color의 기본값을 orange로 주고, inherits(상속)을 받지 않는다