-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_checkboxcustom.html
More file actions
71 lines (70 loc) · 2.51 KB
/
Copy pathtest_checkboxcustom.html
File metadata and controls
71 lines (70 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html lang="kr">
<head>
<meta charset="UTF-8">
<title>checkbox 커스텀</title>
<style>
body{
line-height: 1.5em;
font-weight: bold;
color: black;
}
.custom input[type=checkbox]{
display: none;
}
.custom label em{
display: inline-block;
/* img 사이즈만큼 사이즈 크기를 지정해줘야 한다. */
width: 18px;
height: 18px;
background-image: url(images/checkbox-01.png);
background-repeat: no-repeat;
background-position: left center;
text-align: center;
vertical-align: middle;
margin-right: 10px;
}
/* 'checkbox를 클릭한다'라는 가상클래스는 checked이다.
단, checked는 +인접 선택자와 같이 사용한다.*/
.custom input[type=checkbox]:checked + label em{
background-position: right center;
}
.custom label{
cursor: pointer;
}
.custom input[type=checkbox]:checked + label{
color: crimson;
}
.agree input[type=radio]{
display: none;
}
.agree label em{
display: inline-block;
width: 18px;
height: 18px;
background-image: url(images/radio-01.png);
background-repeat: no-repeat;
background-position: left center;
text-align: center;
vertical-align: middle;
}
.agree input[type=radio]:checked + label em{
background-position: right center;
}
</style>
</head>
<body>
<div class="custom">
<!-- checkbox나 문자를 선택해도 check가 되도록 label 안에 문자를 입력한다.
단, 반드시 input의 id값과 label의 for값이 같아야 한다. -->
<input type="checkbox" id="chk"><label for="chk"><em></em>약관을 충분히 이해하였으며 동의합니다.</label>
</div>
<br><br>
<div class="agree">
<input type="radio" id="radiochk1" name="agree"><label for="radiochk1"><em></em>초등학생</label>
<input type="radio" id="radiochk2" name="agree"><label for="radiochk2"><em></em>중학생</label>
<input type="radio" id="radiochk3" name="agree"><label for="radiochk3"><em></em>고등학생</label>
<input type="radio" id="radiochk4" name="agree"><label for="radiochk4"><em></em>대학생</label>
</div>
</body>
</html>