// element.style.:propertyName = propertyValue
element.style.setStyle('--variantName', variantValue)
element.style.:propertyName 하려고 console에 찍어보니 나오지 않아 당황했다.
style의 setStyle 함수를 이용하여 설정해주면 된다. 간단
box {
--rotation: 0;
transform: rotate(calc(var(--rotation) * 1deg));
}
const box = document.querySelctor('.box') // 방법1
// const box = document.getElementByClassName('box') // 방법2
box.style.setStyle('--rotation', 30)
'A-HA💡 > CSS' 카테고리의 다른 글
[CSS] 그라데이션 종류 (0) | 2024.03.28 |
---|---|
[CSS] CSS, SASS, SCSS, LESS (0) | 2024.01.30 |
[CSS] 반응형 (1) | 2024.01.22 |
[CSS] 네이밍 (0) | 2023.11.07 |
[CSS] 형제 결합자 of 선택자 (0) | 2023.10.23 |