一个挺好的复选框样式,单选框也一样适用

@-moz-keyframes dothabottomcheck {
  0% {
    height: 0;
  }

  100% {
    height: 15px;
  }
}
@-webkit-keyframes dothabottomcheck {
  0% {
    height: 0;
  }

  100% {
    height: 15px;
  }
}
@keyframes dothabottomcheck {
  0% {
    height: 0;
  }

  100% {
    height: 15px;
  }
}
@keyframes dothatopcheck {
  0% {
    height: 0;
  }

  50% {
    height: 0;
  }

  100% {
    height: 30px;
  }
}
@-webkit-keyframes dothatopcheck {
  0% {
    height: 0;
  }

  50% {
    height: 0;
  }

  100% {
    height: 30px;
  }
}
@-moz-keyframes dothatopcheck {
  0% {
    height: 0;
  }

  50% {
    height: 0;
  }

  100% {
    height: 30px;
  }
}
input[type=radio] {
  display: none;
}

.check-box {
  height: 30px;
  width: 30px;
  background-color: transparent;
  border: 4px solid black;
  border-radius: 2px;
  position: absolute;
  display: inline-block;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  -moz-transition: border-color ease 0.2s;
  -o-transition: border-color ease 0.2s;
  -webkit-transition: border-color ease 0.2s;
  transition: border-color ease 0.2s;
  cursor: pointer;
  margin-top: 8px;
}
.check-box::before, .check-box::after {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  position: absolute;
  height: 0;
  width: 5px;
  background-color: #6495ED;
  display: inline-block;
  -moz-transform-origin: left top;
  -ms-transform-origin: left top;
  -o-transform-origin: left top;
  -webkit-transform-origin: left top;
  transform-origin: left top;
  border-radius: 2px;
  content: ' ';
  -webkit-transition: opacity ease .5;
  -moz-transition: opacity ease .5;
  transition: opacity ease .5;
}
.check-box::before {
  top: 19px;
  left: 11px;
  box-shadow: 0 0 0 2px #ffffff;
  -moz-transform: rotate(-135deg);
  -ms-transform: rotate(-135deg);
  -o-transform: rotate(-135deg);
  -webkit-transform: rotate(-135deg);
  transform: rotate(-135deg);
}
.check-box::after {
  top: 9px;
  left: 0px;
  -moz-transform: rotate(-45deg);
  -ms-transform: rotate(-45deg);
  -o-transform: rotate(-45deg);
  -webkit-transform: rotate(-45deg);
  transform: rotate(-45deg);
}

input[type=radio]:checked + .check-box,
.check-box.checked {
  border-color: #6495ED;
}
input[type=radio]:checked + .check-box::after,
.check-box.checked::after {
  height: 10px;
  -moz-animation: dothabottomcheck 0.2s ease 0s forwards;
  -o-animation: dothabottomcheck 0.2s ease 0s forwards;
  -webkit-animation: dothabottomcheck 0.2s ease 0s forwards;
  animation: dothabottomcheck 0.2s ease 0s forwards;
}
input[type=radio]:checked + .check-box::before,
.check-box.checked::before {
  height: 10px;
  -moz-animation: dothatopcheck 0.4s ease 0s forwards;
  -o-animation: dothatopcheck 0.4s ease 0s forwards;
  -webkit-animation: dothatopcheck 0.4s ease 0s forwards;
  animation: dothatopcheck 0.4s ease 0s forwards;
}



<input value="1" type="radio" name="MoreApply" id="isMoreApply">
<label for="isMoreApply" class="check-box"></label>


复选框和单选框的切换就是把样式中input[type=radio]换成input[type=checkbox]


样式效果图





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值