分享一個H5原生form表單的checkbox特效代碼
發(fā)布時間:2018-02-26 15:37:40 作者:Smallwei小偉
我要評論
這篇文章主要介紹了分享一個H5原生form表單的checkbox特效代碼的相關(guān)資料,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
本文介紹了分享一個H5原生form表單的checkbox特效代碼,分享給大家,具體如下:
效果如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.md-checkbox {
margin: 50px;
position: relative;
height: auto;
font-size: 14px;
}
.md-checkbox label>span.inc {
-webkit-animation: growCircle 0.2s ease;
-moz-animation: growCircle 0.2s ease;
animation: growCircle 0.2s ease;
}
@keyframes growCircle {
0%,
100% {
transform: scale(0);
opacity: 0.8;
}
70% {
background: #eee;
transform: scale(1.25);
}
}
.md-checkbox label>span.inc {
background: #fff;
left: -20px;
top: -20px;
height: 60px;
width: 60px;
opacity: 0;
border-radius: 50% !important;
-moz-border-radius: 50% !important;
-webkit-border-radius: 50% !important;
}
.md-checkbox input[type=checkbox] {
visibility: hidden;
position: absolute;
}
.md-checkbox label {
cursor: pointer;
padding-left: 30px;
}
.md-checkbox label>span {
display: block;
position: absolute;
left: 0;
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
transition-duration: 0.2s;
}
.md-checkbox label>.check {
top: -4px;
left: 6px;
width: 10px;
height: 20px;
border: 2px solid #26A69A;
border-top: none;
border-left: none;
opacity: 0;
z-index: 5;
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg);
-webkit-transition-delay: 0.2s;
-moz-transition-delay: 0.2s;
transition-delay: 0.2s;
}
.md-checkbox input[type=checkbox]:checked~label>.check {
opacity: 1;
-webkit-transform: scale(1) rotate(45deg);
-moz-transform: scale(1) rotate(45deg);
transform: scale(1) rotate(45deg);
}
.md-checkbox input[type=checkbox]:checked~label>.box {
opacity: 0;
-webkit-transform: scale(0) rotate(-180deg);
-moz-transform: scale(0) rotate(-180deg);
transform: scale(0) rotate(-180deg);
}
.md-checkbox label>.box {
top: 0px;
border: 2px solid #666;
height: 20px;
width: 20px;
z-index: 5;
-webkit-transition-delay: 0.2s;
-moz-transition-delay: 0.2s;
transition-delay: 0.2s;
}
</style>
</head>
<body>
<div class="md-checkbox">
<input type="checkbox" id="test" class="md-check" />
<label for="test">
<span></span>
<span class="check"></span>
<span class="box"></span>
Option 1
</label>
</div>
<script>
var list = document.getElementsByTagName('input');
for(var i =0;i<list.length;i++){
(function(n){
list[n].addEventListener('click',function(e){
var inc = this.nextElementSibling.firstElementChild;
inc.className = '';
setTimeout(function(){
inc.className = 'inc';
},0);
})
})(i)
}
</script>
</body>
</html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
- checkbox應(yīng)該是一個比較常用的html功能了,不過瀏覽器自帶的checkbox往往樣式不怎么好看,而且不同瀏覽器效果也不一樣.下文給大家分享CSS+HTML自定義checkbox效果,一起看2017-07-03
Html中使用自定義圖片來實現(xiàn)checkbox顯示的方法
下面小編就為大家?guī)硪黄狧tml中使用自定義圖片來實現(xiàn)checkbox顯示的方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-10-18- 下面小編就為大家?guī)硪黄狧TML的checkbox和radio樣式美化的簡單實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-06-08
- 這篇文章主要介紹了使用CSS修改HTML的checkbox效果的小示例分享,主要用到了CSS中的:checked偽類,需要的朋友可以參考下2015-09-07
HTML checkbox 點擊說明文字即可選擇/取消勾選狀態(tài)
由于checkbox比較小用戶操作起來不是很方便,下面就為大家實現(xiàn)下讓用戶點擊說明文字時即可實現(xiàn) 選擇/勾選 checkbox,感興趣的朋友可以參考下2013-11-01

