-
Notifications
You must be signed in to change notification settings - Fork 0
/
radio.htm
72 lines (68 loc) · 2.37 KB
/
radio.htm
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
72
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<style type=text/css>
.sex_div {
position: relative;
float:left;
line-height: 30px;
color: #999;
}
input[type="radio"] {
width: 60px;
height:32px;
opacity: 0;
}
label {
position: absolute;
left: 5px;
top: 3px;
width: 100%;
line-height:32px;
}
/*设置选中的input的样式*/
/* + 是兄弟选择器,获取选中后的label元素*/
input:checked+label {
color:#7ed321;
}
/* ::after 是伪元素 也可以写成 :after*/
input:checked+label::after {
position: absolute;
content: "";
width: 12px;
height: 12px;
top: 10px;
left: 0px;
background-color:#7ED321;
border-radius: 50%;
}
.radio_border{
position:absolute;
border:1px solid #999;
border-radius:50%;
width:16px;
height:16px;
top:7px;
left:-3px;
/*background-color: #e7e7e7;*/
}
</style>
<title>css自定义radio样式</title>
</head>
<body>
<div class="sex_div">
<input id="sex1" type="radio" name="sex" value="0" checked>
<label for="sex1"><div class="radio_border"></div><span style="margin-left:20px;">男孩</span></label>
</div>
<div class="sex_div">
<input id="sex2" type="radio" name="sex" style="margin-left:20px;" value="1">
<label for="sex2"><div class="radio_border"></div><span style="margin-left:20px;">女孩</span></label>
</div>
</body>
</html>