ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

checkbox勾选带动画

2022-06-25 22:36:08  阅读:143  来源: 互联网

标签:checkbox span width transform 勾选 stroke child 带动 cbx


 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Checkbox复选框动画效果</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="style.css">

</head>
<body>
   
        <input class="inp-cbx" id="morning" type="checkbox" style="display: none;">
        <label class="cbx" for="morning">
            <span>
                <svg width="12px" height="10px">
                    <use xlink:href="#check"></use>
                </svg>
            </span><span>Morning</span>
        </label>
        <input class="inp-cbx" id="noon" type="checkbox" style="display: none;">
        <label class="cbx" for="noon">
            <span>
                <svg width="12px" height="10px">
                    <use xlink:href="#check"></use>
                </svg>
            </span><span>Noon</span>
        </label>
        <input class="inp-cbx" id="afternoon" type="checkbox" style="display: none;">
        <label class="cbx" for="afternoon">
            <span>
                <svg width="12px" height="10px">
                    <use xlink:href="#check"></use>
                </svg>
            </span><span>Afternoon</span>
        </label>
        <input class="inp-cbx" id="evening" type="checkbox" style="display: none;">
        <label class="cbx" for="evening">
            <span>
                <svg width="12px" height="10px">
                    <use xlink:href="#check"></use>
                </svg>
            </span><span>Evening</span>
        </label>
        <!--SVG Sprites-->
        <svg class="inline-svg">
            <symbol id="check" viewBox="0 0 12 10">
                <polyline points="1.5 6 4.5 9 10.5 1"></polyline>
            </symbol>
        </svg>
 
</body>
</html>

  

   * {
  box-sizing: border-box;
}
.cbx {
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  overflow: hidden;
  transition: all 0.2s ease;
}
.cbx:not(:last-child) {
  margin-right: 6px;
}
.cbx:hover {
  background: rgba(125,100,247,0.06);
}
.cbx span {
  float: left;
  vertical-align: middle;
  transform: translate3d(0, 0, 0);
}
.cbx span:first-child {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  transform: scale(1);
  border: 2px solid #c8ccd4;
  transition: all 0.2s ease;
}
.cbx span:first-child svg {
  position: absolute;
  top: 2px;
  left: 1px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 16px;
  stroke-dashoffset: 16px;
  transition: all 0.3s ease;
  transition-delay: 0.1s;
  transform: translate3d(0, 0, 0);
}
.cbx span:last-child {
  padding-left: 8px;
  line-height: 18px;
}
.cbx:hover span:first-child {
  border-color: #7d64f7;
}
.inp-cbx:checked + .cbx span:first-child {
  background: #7d64f7;
  border-color: #7d64f7;
  animation: wave 0.4s ease;
}
.inp-cbx:checked + .cbx span:first-child svg {
  stroke-dashoffset: 0;
}
body {
  font-family: "Open Sans", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizelegibility;
  color: #223254;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
.inline-svg {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  user-select: none;
}
@media screen and (max-width: 640px) {
  body {
    width: auto;
    display: inherit;
    padding: 20px;
  }
  .cbx {
    width: 100%;
    margin-bottom: 4px;
    display: inline-block;
  }
}
@-moz-keyframes wave {
  50% {
    transform: scale(0.9);
  }
}
@-webkit-keyframes wave {
  50% {
    transform: scale(0.9);
  }
}
@-o-keyframes wave {
  50% {
    transform: scale(0.9);
  }
}
@keyframes wave {
  50% {
    transform: scale(0.9);
  }
}

  

标签:checkbox,span,width,transform,勾选,stroke,child,带动,cbx
来源: https://www.cnblogs.com/zmdComeOn/p/16412548.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有