【发布时间】:2018-10-13 02:12:53
【问题描述】:
我尝试制作一个自定义单选按钮,单击该按钮时会改变颜色、播放和动画。但是我只能通过悬停来做到这一点,我尝试使用“输入:检查”但它几乎没有用
当我将鼠标悬停在单选按钮上时,会发生动画,但我希望在单击单选按钮时发生动画。请帮我解决这个问题!
body{
margin: 0;
padding: 0;
}
.choose{
margin: 0;
padding: 0;
position: relative;
top: 0px;
display: block;
background: #262626;
height: 209px;
}
.choose input{
-webkit-appearance: none;
}
.choose #female{
position: absolute;
left: 65%;
}
.choose #male, #female{
position: absolute;
top: 50%;
left: 35%;
transform: translate(-50%,-50%);
background: #ffffff;
width: 70px;
height: 70px;
text-align: center;
border-radius: 50%;
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
transition: .5s;
font-size: 24px;
color: #262626;
}
.choose #male:hover{
background: #3c81de;
color: white;
}
.choose #female:hover{
background: #f23895;
color: white;
}
.choose #male .fas{
display: block;
line-height: 70px;
border-radius: 50%;
}
.choose #female .fas{
display: block;
line-height: 70px;
border-radius: 50%;
}
.choose #male .fas:hover{
animation: manimate 7s;
}
@keyframes manimate{
0%{
box-shadow: 0 0 0 0 rgb(90, 168, 217)
}
12%{
box-shadow: 0 0 0 50px rgba(255,109,74,0)
}
80%{
box-shadow: 0 0 0 0px rgba(255,109,74,0)
}
100%{
box-shadow: 0 0 0 50px rgba(255,109,74,0)
}
}
.choose #female .fas:hover{
animation: fanimate 7s;
}
@keyframes fanimate{
0%{
box-shadow: 0 0 0 0 rgba(237, 110, 173, 0.98)
}
12%{
box-shadow: 0 0 0 50px rgba(255,109,74,0)
}
80%{
box-shadow: 0 0 0 0px rgba(255,109,74,0)
}
100%{
box-shadow: 0 0 0 50px rgba(255,109,74,0)
}
}
<!DOCTYPE html>
<html>
<head>
<title>mvrikxix's Arena</title>
<link rel="stylesheet" href="PlaywithButtons.css">
<link rel="icon" href="mvrikxix.png">
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<link href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" rel="stylesheet">
</head>
<body>
<div class="choose">
<label>
<input type="radio"><span id="male")><i class="fas fa-mars"></i></span></input>
<input type="radio"><span id="female"><i class="fas fa-venus"></i></span></input>
</label>
</div>
</body>
</html>
【问题讨论】:
标签: html css radio-button css-animations html-input