-
[CSS] accent-color ์์ฑ์ผ๋ก ํผ ์์ ์คํ์ผ๋งํ๊ธฐCoding 2025. 3. 6. 22:21๋ฐ์ํ
์น์ฌ์ดํธ์์ ์ฒดํฌ๋ฐ์ค, ๋ผ๋์ค ๋ฒํผ, ํ๋ก๊ทธ๋ ์ค ๋ฐ ๋ฑ ๊ธฐ๋ณธ UI ์์์ ์์์ ๋ณ๊ฒฝํ๋ ๊ฒ์ ์ข ์ข ๊น๋ค๋กญ์ต๋๋ค.
CSS์ accent-color ์์ฑ์ ์ฌ์ฉํ๋ฉด ํ ์ค์ ์ฝ๋๋ก ์์ฝ๊ฒ ์ฃผ์ UI ์์์ ์์์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
accent-color๋ฅผ ์ฌ์ฉํ ์ ์๋ HTML ์์
HTML ์์ <input type="checkbox"> <input type="radio"> <input type="range"> <progress>
์ฒดํฌ๋ฐ์ค & ๋ผ๋์ค ๋ฒํผ ์์ ๋ณ๊ฒฝ
<h3>์ฒดํฌ๋ฐ์ค</h3> <input type="checkbox" checked> <h3>๋ผ๋์ค ๋ฒํผ</h3> <input type="radio" name="option" checked>
input { accent-color: #3498db; /* ํ๋์ */ }
์ฒดํฌ๋ฐ์ค์ ๋ผ๋์ค ๋ฒํผ์ ๊ธฐ๋ณธ ๊ฐ์กฐ ์์์ด ํ๋์(#3498db) ์ผ๋ก ๋ณ๊ฒฝ๋ฉ๋๋ค.
์ฌ๋ผ์ด๋ & ํ๋ก๊ทธ๋ ์ค ๋ฐ ์คํ์ผ ๋ณ๊ฒฝ
<h3>๋ฒ์ ์ฌ๋ผ์ด๋</h3> <input type="range" min="0" max="100" value="50"> <h3>ํ๋ก๊ทธ๋ ์ค ๋ฐ</h3> <progress value="50" max="100"></progress>
input[type="range"], progress { accent-color: #e74c3c; /* ๋นจ๊ฐ์ */ }
range์ progress ๋นจ๊ฐ์(#e74c3c) ์ผ๋ก ๋ณ๊ฒฝ.
๋ฒ์ ์ฌ๋ผ์ด๋(range)์ ํ๋ก๊ทธ๋ ์ค ๋ฐ(progress)์ ์์๋ ์ฝ๊ฒ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
accent-color ๋คํฌ ๋ชจ๋์์ ํ์ฉํ๊ธฐ
/* ๊ธฐ๋ณธ ๋ผ์ดํธ ๋ชจ๋ */ input { accent-color: #3498db; /* ํ๋์ */ } /* ๋คํฌ ๋ชจ๋ */ @media (prefers-color-scheme: dark) { input { accent-color: #f1c40f; /* ๋ ธ๋์ */ } }
์ฌ์ฉ์์ ์ด์์ฒด์ ์ค์ ์ ๋ฐ๋ผ
๋ผ์ดํธ ๋ชจ๋์์๋ ํผ ์์์ ์์์ด ํ๋์(#3498db)
๋คํฌ ๋ชจ๋์์๋ ๋ ธ๋์(#f1c40f) ์ผ๋ก ๋ณ๊ฒฝ๋จ!
+ ๊ตฌํ ๋ฒ์ ์ ์ผ์ฑ ์ธํฐ๋ท ๋ธ๋ผ์ฐ์ ๋ ์ ๋ฐ์ดํธ๋์ง ์์ ๊ธฐ๊ธฐ์์ ๋์ฒด ์คํ์ผ๋ง ๋ฐฉ๋ฒ
/* accent-color๋ฅผ ์ง์ํ์ง ์๋ ๋ธ๋ผ์ฐ์ ๋ฅผ ์ํ ๊ธฐ๋ณธ ์คํ์ผ */ input[type="checkbox"] { appearance: none; width: 20px; height: 20px; background-color: #fff; border: 2px solid #000; } input[type="checkbox"]:checked { background-color: #3498db; /* ์ํ๋ ๊ฐ์กฐ ์์ */ } /* accent-color๋ฅผ ์ง์ํ๋ ๋ธ๋ผ์ฐ์ ๋ฅผ ์ํ ์คํ์ผ */ @supports (accent-color: auto) { input[type="checkbox"] { appearance: auto; accent-color: #3498db; } }
@supports ๊ท์น์ ์ฌ์ฉํ์ฌ ๋ธ๋ผ์ฐ์ ๊ฐ accent-color ์์ฑ์ ์ง์ํ๋์ง ํ์ธํ๊ณ ,
์ง์ํ๋ ๊ฒฝ์ฐ์๋ ํด๋น ์์ฑ์ ์ฌ์ฉํ์ฌ ์คํ์ผ์ ์ ์ฉํฉ๋๋ค.
๋ฐ์ํ'Coding' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[CSS] filter: invert() ์ฌ์ฉ๋ฒ (0) 2025.03.05 [CSS] Grid vs Flexbox: ์ด๋ค ์ํฉ์์ ์ด๋ค ๊ฑธ ์ ํํด์ผ ํ ๊น? (0) 2025.03.04 [CSS] linear-gradient() ์ฌ์ฉํ๊ธฐ (0) 2024.08.12 [GSAP] scrollTo() ํจ์ ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ (0) 2024.06.02 [GSAP] ScrollTrigger ์์ ์์ ๋ฆฌํด ๊ฐ ์ป๋ ๋ฐฉ๋ฒ (0) 2024.03.05