0
点赞
收藏
分享

微信扫一扫

在Ubuntu20.04.6上编译Qt5.15.2源码并安装

大家好,我是 Just,这里是「设计师工作日常」,今天分享的是用 css 实现一个圆形背景动效多选框,适用提醒用户勾选场景,突出多选框选项,可以有效增加用户识别度。

最新文章通过公众号「设计师工作日常」发布。


目录

整体效果

适用提醒用户勾选场景,突出多选框选项,可以有效增加用户识别度。


核心代码部分,简要说明了写法思路;完整代码在最后,可直接复制到本地运行。

核心代码

html 代码

<label class="label66">
  <input type="checkbox" class="check-inp66">
  <span class="span66"></span>
</label>

css 部分代码

.label66{
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}
.check-inp66{
  width: 40px;
  height: 40px;
  border-radius: 50%;
  position: absolute;
  background-color: rgba(0, 0, 0, 0.06);
  z-index: 1;
  transform: scale(1);
  transition: transform 0.15s linear;
  appearance: none; /* none时可以自定义其外观 */
}
.span66{
  width: 20px;
  height: 20px;
  display: block;
  position: absolute;
  z-index: 2;
  cursor: pointer;
}
.span66::before{
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0,0,0,0.6);
  border-radius: 3px;
  box-sizing: border-box;
  display: block;
  position: absolute;
  transition: all 0.3s linear;
}
.span66::after{
  content: "";
  width: 10px;
  height: 5px;
  display: block;
  position: absolute;
  top: 5px;
  left: 4px;
  border: solid 2px transparent;
  border-right: none;
  border-top: none;
  transform: rotate(-45deg);
  transition: border-color 0.3s linear;
}
.label66:hover .span66::before{
  border-color: #0093E9;
}
.label66:active .check-inp66,.label66:active .check-inp66:checked{
  transform: scale(0);
  transition: transform 0.15s linear;
}
.check-inp66:checked{
  background-color: rgba(0,147,233,0.08);
}
.check-inp66:checked ~ .span66::before{
  background-color: #0093E9;
  border-color: #0093E9;
}
.check-inp66:checked ~ .span66::after{
  border-color: #ffffff;
}

完整代码如下

html 页面

<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">
    <title>圆形背景动效多选框</title>
  </head>
  <body>
    <div class="app">
      <label class="label66">
        <input type="checkbox" class="check-inp66">
        <span class="span66"></span>
      </label>
    </div>
  </body>
</html>

css 样式

/** style.css **/
.app{
  width: 100%;
  height: 100vh;
  background-color: #ffffff;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}
.label66{
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}
.check-inp66{
  width: 40px;
  height: 40px;
  border-radius: 50%;
  position: absolute;
  background-color: rgba(0, 0, 0, 0.06);
  z-index: 1;
  transform: scale(1);
  transition: transform 0.15s linear;
  appearance: none; /* none时可以自定义其外观 */
}
.span66{
  width: 20px;
  height: 20px;
  display: block;
  position: absolute;
  z-index: 2;
  cursor: pointer;
}
.span66::before{
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0,0,0,0.6);
  border-radius: 3px;
  box-sizing: border-box;
  display: block;
  position: absolute;
  transition: all 0.3s linear;
}
.span66::after{
  content: "";
  width: 10px;
  height: 5px;
  display: block;
  position: absolute;
  top: 5px;
  left: 4px;
  border: solid 2px transparent;
  border-right: none;
  border-top: none;
  transform: rotate(-45deg);
  transition: border-color 0.3s linear;
}
.label66:hover .span66::before{
  border-color: #0093E9;
}
.label66:active .check-inp66,.label66:active .check-inp66:checked{
  transform: scale(0);
  transition: transform 0.15s linear;
}
.check-inp66:checked{
  background-color: rgba(0,147,233,0.08);
}
.check-inp66:checked ~ .span66::before{
  background-color: #0093E9;
  border-color: #0093E9;
}
.check-inp66:checked ~ .span66::after{
  border-color: #ffffff;
}

页面渲染效果

以上就是所有代码,以及简单的思路,希望对你有一些帮助或者启发。


[1] 原文阅读


网站《有趣的css》上线了,目前已上线 demo 实例 65 例,欢迎大家访问。

网站:Funcss


我是 Just,这里是「设计师工作日常」,求点赞求关注!

举报

相关推荐

0 条评论