gpt4 book ai didi

javascript - 取消选中复选框 css3 动画

转载 作者:太空宇宙 更新时间:2023-11-04 14:03:37 24 4
gpt4 key购买 nike

当我的复选框被选中时我有一个动画,但我想在它们未被选中时反转动画。我尝试了伪类 :unchecked,但我发现它不起作用。是否有 CSS3 方法或可能是一个小的 jQuery 修复?

@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,600,700);
@keyframes checked {
0% {
tranform: scale(1);
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
}

* {
box-sizing: border-box;
}

body {
color: #fff;
font-family: "Open Sans";
background: #DA5838;
padding: 20px;
}

h2 {
font-size: 24px;
margin-bottom: 14px;
}

div {
margin-bottom: 18px;
}

input[type="radio"],
input[type="checkbox"] {
display: none;
}

input[type="radio"]+label,
input[type="checkbox"]+label {
appearance: none;
cursor: pointer;
display: inline-block;
padding-left: 34px;
position: relative;
vertical-align: middle;
}

input[type="radio"]:checked+label,
input[type="checkbox"]:checked+label {
backface-visibility: hidden;
animation: checked 200ms ease 1;
}

input[type="radio"]+label:before {
background: none repeat scroll 0 0 rgba(255, 255, 255, 0);
border-radius: 100% 100% 100% 100%;
content: " ";
height: 7px;
left: 12px;
position: absolute;
top: 6px;
width: 7px;
}

input[type="radio"]+label:hover:before {
background: none repeat scroll 0 0 rgba(255, 255, 255, 0.5);
}

input[type="radio"]:checked+label:before {
background: none repeat scroll 0 0 rgba(255, 255, 255, 1);
}

input[type="checkbox"]+label:before {
content: '';
position: absolute;
width: 7px;
height: 3px;
top: 6px;
left: 11px;
border: 2px solid rgba(255, 255, 255, 0);
border-top: none;
border-right: none;
transform: rotate(-45deg);
}

input[type="checkbox"]+label:hover:before {
border-color: rgba(255, 255, 255, 0.5);
}

input[type="checkbox"]:checked+label:before {
border-color: rgba(255, 255, 255, 1);
}

input[type="radio"]+label:after,
input[type="checkbox"]+label:after {
border: 3px solid #FFFFFF;
border-radius: 100% 100% 100% 100%;
content: " ";
height: 15px;
left: 5px;
position: absolute;
top: -1px;
width: 15px;
}

input[type="radio"]:checked+label:after,
input[type="checkbox"]:checked+label:after {
border-color: rgba(255, 255, 255, 1);
}
<div>
<input type="radio" name="rr" id="r1">
<label for="r1">Radio Button 1</label>
</div>
<div>
<input type="radio" name="rr" id="r2">
<label for="r2">Radio Button 2</label>
</div>
<div>
<input type="radio" name="rr" id="r3">
<label for="r3">Radio Button 3</label>
</div>
<div>
<input type="radio" name="rr" id="r4">
<label for="r4">Radio Button 4</label>
</div>
<br/><br/>
<div>
<input type="checkbox" name="cc" id="c1">
<label for="c1">Checkbox Button 1</label>
</div>
<div>
<input type="checkbox" name="cc" id="c2">
<label for="c2">Checkbox Button 2</label>
</div>
<div>
<input type="checkbox" name="cc" id="c3">
<label for="c3">Checkbox Button 3</label>
</div>
<div>
<input type="checkbox" name="cc" id="c4">
<label for="c4">Checkbox Button 4</label>
</div>

CodePen Demo

最佳答案

简单的解决方案是最好的!

:not(:checked)

关于javascript - 取消选中复选框 css3 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19684204/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com