์๊ตฌ์ฌํญ
- CSS ๋ณ์ ์ค์ (Root Variables):
- ๋ฌธ์์ ์ต์์ ์์ (:root)์ ๋ค์ ์ด๋ฆ๊ณผ ๊ฐ์ผ๋ก CSS ๋ณ์๋ฅผ ์ ์ธํฉ๋๋ค.
- --main-color: #6a5acd (๋ฐ์ ๋ณด๋ผ์ ๊ณ์ด)
- --border-radius: 4px
- --spacing: 8px
- --font-size: 16px
- ๋ฌธ์์ ์ต์์ ์์ (:root)์ ๋ค์ ์ด๋ฆ๊ณผ ๊ฐ์ผ๋ก CSS ๋ณ์๋ฅผ ์ ์ธํฉ๋๋ค.
- HTML ๊ตฌ์กฐ:
- <div class="input-group"> ์์ <label> ํ๊ทธ์ <input type="text"> ํ๊ทธ๋ฅผ ๋ง๋ญ๋๋ค.
- label ํ ์คํธ๋ "์ฌ์ฉ์ ์ด๋ฆ"์ผ๋ก, input์๋ placeholder="์ด๋ฆ์ ์ ๋ ฅํ์ธ์"๋ฅผ ๋ฃ์ต๋๋ค.
- CSS - ์
๋ ฅ ๊ทธ๋ฃน ์คํ์ผ:
- .input-group์ ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ํ๋จ ์ฌ๋ฐฑ์ ์ค์ ํฉ๋๋ค. (๋ณ์ --spacing์ 2๋ฐฐ)
- CSS - ์
๋ ฅ ํ๋ ์คํ์ผ (input):
- <input> ํ๊ทธ์ ๋ค์ ์คํ์ผ์ ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ์ ์ฉํฉ๋๋ค.
- ๋๋น: 100%
- ํจ๋ฉ: ๋ณ์ --spacing์ ์ฌ์ฉํ์ฌ ์ํ์ข์ฐ์ ์ ์ฉํฉ๋๋ค.
- ๊ธ๊ผด ํฌ๊ธฐ: ๋ณ์ --font-size๋ฅผ ์ฌ์ฉํฉ๋๋ค.
- ํ ๋๋ฆฌ ๊ตต๊ธฐ์ ์คํ์ผ: 1px solid #ccc
- ๋ชจ์๋ฆฌ ๋ฅ๊ธ๊ฒ: ๋ณ์ --border-radius๋ฅผ ์ฌ์ฉํฉ๋๋ค.
- <input> ํ๊ทธ์ ๋ค์ ์คํ์ผ์ ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ์ ์ฉํฉ๋๋ค.
- CSS - ํฌ์ปค์ค ํจ๊ณผ:
- <input> ํ๋์ **ํฌ์ปค์ค (:focus)**๊ฐ ๋์์ ๋,
- ํ ๋๋ฆฌ ์์์ **๋ณ์ --main-color**๋ก ๋ณ๊ฒฝํ๊ณ ๊ตต๊ธฐ๋ฅผ 2px๋ก ๋ณ๊ฒฝํฉ๋๋ค.
- ์์๋ผ์ธ (outline)์ ์ ๊ฑฐํฉ๋๋ค.
- <input> ํ๋์ **ํฌ์ปค์ค (:focus)**๊ฐ ๋์์ ๋,
- CSS - ํ
๋ง ๋ณ๊ฒฝ (์ฌ์ฌ์ฉ์ฑ ํ์ธ):
- .dark-theme ํด๋์ค๋ฅผ ํ๋ ๋ง๋ค๊ณ , ์ด ํด๋์ค๊ฐ body์ ์ ์ฉ๋ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ์ฌ **๋ณ์ --main-color**์ ๊ฐ์ **#ff6347 (๋ฐ์ ์ฃผํฉ์ ๊ณ์ด)**๋ก ์ฌ์ ์ํฉ๋๋ค.
- (์ ํ) body์ ์ด ํด๋์ค๋ฅผ ์ ์ฉํ์ ๋, .input-group์ด ์ด๋ค ๋ณํ๋ฅผ ๋ณด์ด๋์ง ํ์ธํด ๋ด ๋๋ค. (์ฝ๋ ์ ์ถ ์์๋ body์ ์ด ํด๋์ค๋ฅผ ์ ์ฉํ์ง ์์๋ ๋ฉ๋๋ค.)
๋๋ณด๊ธฐ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
:root {
--main-color: #6a5acd;
--border-radius: 4px;
--spacing: 8px;
--font-size: 16px
}
.input-group {
margin-bottom: calc(var(--spacing) * 2);
}
.input-group input {
width: 100%;
padding: var(--spacing);
border: 1px solid #ccc;
border-radius: var(--border-radius);
font-size: var(--font-size);
}
.input-group input:focus {
border: 2px solid var(--main-color);
outline: 0;
}
.dark-theme:root {
--main-color: #ff6347;
}
</style>
</head>
<body>
<div class="input-group">
<label for="">์ฌ์ฉ์ ์ด๋ฆ : <input type="text" name="" id="" placeholder="์ด๋ฆ์ ์
๋ ฅํ์ธ์."></label>
</div>
</body>
</html>
