2 回答

TA貢獻1820條經(jīng)驗 獲得超10個贊

TA貢獻1783條經(jīng)驗 獲得超4個贊
其實你可以直接將其display:none隱藏的,用label for id 來綁定input,點擊label來控制 radio
input[type="radio"]{
opacity: 0;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="normalize.css"/>
<style type="text/css">
input[type="checkbox"]:checked+label:after{
content: '\2714';
background-color: #ff5757;
color: #FFF;
border-color: #ff5757;
}
input[type="checkbox"]{
display: none;
}
label:after{
content: '';
position: absolute;
left: 0;
top: 0;
width: 18px;
height: 18px;
border: 1px solid #CCC;
box-sizing: border-box;
line-height: 18px;
text-align: center;
border-radius: 3px;
font-size: 14px;
}
label{
position: relative;
padding-left: 25px;
box-sizing: border-box;
line-height: 20px;
font-size: 14px;
height: 20px;
}
#top{
margin: 100px;
}
input[type="checkbox"]:checked ~ img{
transform: translateX(500px);
}
#img{
transition: all 1s;
}
</style>
</head>
<body>
<div id="top">
<input type="checkbox" id="mycheck"/>
<label for="mycheck">噓噓噓噓噓</label>
<img src="2.jpg" id="img" alt="" />
</div>
</body>
</html>
添加回答
舉報