Css Javascript
const inputs = document.querySelectorAll('.controls input');
function handleUpdate() {
const suffix = this.dataset.sizing || ''; // || ์ ๋ฃ๋์ด์ ๋ data-sizing๊ฐ์ด ๊ฐ์๊ฒฝ์ฐ ์๊ธฐ๋๋ฌธ์ ๋ฃ์ด์ค ์์๋๋ ๊ณต๋ฐฑ์ฒ๋ฆฌ๋๊ฒ ํด์ค
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
// css ์์ฑ์ ์ฌํ ๋น ์ํด (IE8 ์ดํ๋ setaAttribute๋ฅผ ์จ์ผํจ)
}
inputs.forEach(input => input.addEventListener('change', handleUpdate));
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
:root
:root
๋ ๊ฐ์ ์ ํ์์ด๊ธฐ ๋๋ฌธ์, html ์
๋ ํฐ๋ณด๋ค๋ ์ฐ์ ์์๊ฐ ๋์ต๋๋ค. ๊ทธ๋์ :root์ html์ ๋ํ ์คํ์ผ์ ๋์์ ์ ์ธํ๋ฉด, :root์ ๋ํ ์คํ์ผ์ด ์ฐ์ ๋ฉ๋๋ค.
root๋ ์ ์ญ ์ค์ฝํ์ CSS ๋ณ์(์ฌ์ฉ์ ์ ์ CSS์์ฑ)๋ฅผ ์ ์ธํ ๋ ์ฌ์ฉ

Last updated
Was this helpful?