-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_checkbox_css.html
51 lines (50 loc) · 1.34 KB
/
input_checkbox_css.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="css/css.css" />
<style>
input.d_check {
position: absolute;
clip: rect(0, 0, 0, 0);
}
input[type="checkbox"].d_check + label::before {
content: "\a0"; /*不换行空格*/
display: inline-block;
vertical-align: .2em; /*小盒子的高度*/
width: .8em;
height: .8em;
margin-right: .2em;
border-radius: .2em;
background-color: white;
border: 1px solid #ccc;
line-height: .65; /*行高不加单位,子元素将继承数字乘以自身字体尺寸而非父元素行高*/ /*行高可以确定之间的高度*/
}
input[type="checkbox"]:checked.d_check + label::before {
content: "\2713";
background-color: yellowgreen;
}
input[type="checkbox"]:focus.d_check + label::before {
box-shadow: 0 0 .1em .1em #58a;
}
input[type="checkbox"]:disabled.d_check + label::before {
background-color: gray;
box-shadow: none;
color: #555;
}
.ddd{
background: aquamarine;
width: 300px;
height: 300px;
margin: 0 auto;
}
</style>
</head>
<body >
<div class="ddd">
<input type="checkbox" id="awesome" class="d_check"/>
<label for="awesome">Awesome hello hello!</label>
</div>
</body>
</html>