๐จ Frontend/HTML & CSS
HTML - ์ฐ์ต ๋ฌธ์ (์ง์์, ์ฃผ๋ฌธํ๊ธฐ ํผ ๋ง๋ค๊ธฐ)
kongmi
2023. 3. 9. 18:21
1๋ฒ ๋ฌธ์
์กฐ๊ฑด
- ํผ ์์๋ฅผ ์ฝ์ ํ ๋ <label> ํ๊ทธ ์ฌ์ฉ
- ‘์ด๋ฆ'ํ๋๋ ํ ์คํธ ํ๋๋ก ์ฝ์ ํ๊ณ ‘๊ณต๋ฐฑ์์ด ์ ๋ ฅํ์ธ์'๋ผ๋ ํํธ ํ์
- ‘์ฐ๋ฝ์ฒ' ํ๋๋ ์ ํ๋ฒํธ์ ๋ง๋ ํ๋๋ก ์ฝ์
- ‘์ง์ ๋๊ธฐ'๋ ํ ์คํธ๋ฅผ ์ฌ๋ฌ ์ค ์ ๋ ฅ ํ ์ ์๋ ํ ์คํธ ์์ญ ํ๋๋ก ์ฝ์
- ํ ์คํธ ์์ญ์ ๊ธ์ ์๋ 70์, ํ๋ฉด์ ํ์ํ ์ค ๊ฐ์๋ 5๊ฐ๋ก ์ง์
- ๋ฒํผ์ <input> ํ๊ทธ๋ <button> ํ๊ทธ๋ฅผ ์ด์ฉํด ๋ง๋ค๊ธฐ
์ฝ๋
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>์ฐ์ต๋ฌธ์ 2</title>
<style>
.container {
width: 560px;
border: 1px solid black;
padding: 20px 40px;
}
.detail {
margin: 4px 40px;
}
</style>
</head>
<body>
<!-- ๋ฐ๊นฅ ํ์ ๋ง๋ค๊ธฐ ์ํด div ํ๊ทธ ๋ฃ๊ธฐ (style์ class ์ ์)-->
<!-- ๊ธฐ๋ณธ ์ฌ๋ฐฑ๋ค์ด ์์ด์ ์คํ์ผ ๋ ๋ฆฌ๊ณ ํด๋ณด์ -->
<div class="container">
<h1>ํ๋ก ํธ์ค๋ ๊ฐ๋ฐ์ ์ง์์</h1>
<p>HTML, CSS, Javascript์ ๋ํ ๊ธฐ์ ์ ์ดํด์ ๊ฒฝํ์ด ์๋ ๋ถ์ ์ฐพ์ต๋๋ค.</p>
<hr>
<form action="#">
<h4>๊ฐ์ธ์ ๋ณด</h4>
<div class="detail">
<label for="name">์ด๋ฆ</label>
<input type="text" id="name" placeholder="๊ณต๋ฐฑ์์ด ์
๋ ฅํ์ธ์.">
</div>
<div class="detail">
<label for="tel">์ฐ๋ฝ์ฒ</label>
<input type="text" id="tel">
</div>
<h4>์ง์๋ถ์ผ</h4>
<div class="detail">
<input type="radio" name="field" id="publish" value="1">
<label for="publish">์นํผ๋ธ๋ฆฌ์ฑ</label>
</div>
<div class="detail">
<input type="radio" name="field" id="front" value="2">
<label for="front">ํ๋ก ํธ์ค๋</label>
</div>
<div class="detail">
<input type="radio" name="field" id="mobile" value="3">
<label for="mobile">๋ชจ๋ฐ์ผ์ฑ</label>
</div>
<h4>์ง์๋๊ธฐ</h4>
<textarea name="desc" id="" cols="70" rows="5" placeholder="๋ณธ์ฌ ์ง์ ๋๊ธฐ๋ฅผ ๊ฐ๋ตํ ์จ ์ฃผ์ธ์.">
</textarea>
<button type="submit">์ ์ํ๊ธฐ</button>
<button type="reset">๋ค์์ฐ๊ธฐ</button>
</form>
</div>
</body>
</html>
class
์ง์ ํด์style
์ ์ฉํ๊ธฐdiv
ํ๊ทธ๋ก ๋ธ๋ก(?) ๋๋๊ธฐ- ์ถํ ์๋ฒ๋ก ๋ฐ์ดํฐ ๋ณด๋ด๊ธฐ ์ํ
form
ํ๊ทธ ๊ฐ์ธ๊ธฐ
2๋ฒ ๋ฌธ์
์กฐ๊ฑด
- ์ฃผ๋ฌธ ์ํ์ readonly
- ๋ฐฐ์ก์ง ์ฃผ์๋ ํ์ ์ฌํญ
์ฝ๋
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>์ฐ์ต๋ฌธ์ 3๋ฒ</title>
<style>
label {
display: inline-block;
width: 100px;
margin-bottom: 8px;
}
input {
width: 300px;
height: 24px;
margin-bottom: 10px;
}
input[type="date"] {
width: 150px;
}
button {
width: 150px;
height: 40px;
margin-left: 10px;
margin-right: 10px;
}
.btn {
margin-top: 20px;
display: flex;
justify-content: center;
}
span {
font-size: 80%;
}
</style>
</head>
<body>
<h1>์์ดํจ๋ ์ฃผ๋ฌธํ๊ธฐ</h1>
<form action="#">
<fieldset>
<legend>๋ฐฐ์ก ์ ๋ณด</legend>
<div>
<label for="product">์ฃผ๋ฌธ ์ํ</label>
<input type="text" id="product" value="์์ดํจ๋ 12.9์ธ์น" readonly>
</div>
<div>
<label for="name">์ด๋ฆ</label>
<input type="text" id="name" autofocus>
</div>
<div>
<label for="address">๋ฐฐ์ก ์ฃผ์</label>
<input type="text" id="address" required>
</div>
<div>
<label for="mail">์ด๋ฉ์ผ</label>
<input type="text" id="mail">
</div>
<div>
<label for="tel">์ฐ๋ฝ์ฒ</label>
<input type="text" id="tel" placeholder="ํ์ดํ ๋นผ๊ณ ์
๋ ฅํด ์ฃผ์ธ์.(01012345678)">
</div>
<div>
<label for="date">๋ฐฐ์ก์ผ ์ง์ </label>
<input type="date" id="date">
<span>(์ฃผ๋ฌธ์ผ๋ก๋ถํฐ ์ต์ 3์ผ ์ดํ)</span>
</div>
</fieldset>
<div class="btn">
<button type="submit">์ฃผ๋ฌธํ๊ธฐ</button>
<button type="submit">์ทจ์ํ๊ธฐ</button>
</div>
</form>
</body>
</html>
- ์ผ๋ถ๋ถ๋ง
style
์ ์ฉํ๊ธฐ
์์)input [type="date"] {}