web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

css美化input-checkbox多选框代码

219 ℃
     

利用css代码美化input-checkbox多选框样式,具体实现代码如下!点击查看input-checkbox多选框效果!​

html代码:

<div class="content">
  <div class="section">
    <label class="checkbox" for="agree1">
      <input type="checkbox" id="agree1">
      <span>选项样式一</span>
    </label>
  </div>
  <div class="section">
    <label class="input-checkbox">
      <input type="checkbox" class="agree2">
      <span class="agree-box"></span>
      <span>选项样式二</span>
    </label>
  </div>
</div>

css代码:

html,body,.content {
  height:100%;
}
:root {
  --bright-blue: rgb(0, 100, 255);
  --bright-green: rgb(0, 255, 0);
  --bright-red: rgb(255, 0, 0);
  --background: black;
  --foreground: white;
  --border-size: 2px;
  --border-radius: 0.75em;
}
body {
  background: var(--background);
  color: var(--foreground);
  min-height: 100dvh;
  display: grid;
  place-content: center;
  margin: 0;
  font-family: "Aspekta";
}
.content {
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
}
.section {
  width:300px;
  margin:5px;
  font-size:18px
}
.checkbox {
  position:relative;
  padding-left:1.5em;
  cursor:pointer
}
.checkbox input {
  display:none;
}
.checkbox span {
  display:inline-block;
  user-select:none;
}
.checkbox span::before,.checkbox span::after {
  content:'';
  position:absolute;
  left:0;
  top:50%;
  transform:translateY(-50%);
  width:1em;
  height:1em;
  border:1px solid #ccc;
  border-radius:3px;
  transition:200ms;
}
.checkbox span::before {
  width:1em;
  height:1em;
  border:1px solid #444;
}
.checkbox span::after {
  width:0.6em;
  height:0.6em;
  left:0.2em;
  background-color:#579ef8;
  border-color:#579ef8;
  opacity:0;
}
.checkbox input:checked ~ span::before {
  border-color:#579ef8;
}
.checkbox input:checked ~ span::after {
  opacity:1
}
.input-checkbox {
  position:relative;
  display:flex;
  align-items:center;
  cursor:pointer
}
.agree-box {
  margin-right:6px;
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:18px;
  background:#579ef8;
  border-radius:3px;
  box-shadow:inset 0 0 0 1px #949aa4;
  transition:background 250ms ease,box-shadow 250ms ease;
  overflow:hidden;
}
.agree-box::before,.agree-box::after {
  content:'';
  position:absolute;
  left:8px;
  bottom:4px;
  width:0;
  height:2px;
  background-color:#fff;
  border-radius:3px;
  transform-origin:center left;
  transition:width 200ms ease;
}
.agree-box::before {
  transform:rotate(45deg);
  left:4px;
  bottom:9px;
  transition-delay:180ms
}
.agree-box::after {
  transform:rotate(-50deg);
  transition-delay:0ms
}
.input-checkbox:active .agree-box {
  box-shadow:inset 0 0 0 2px #596170
}
.agree2 {
  position:absolute;
  width:0;
  height:0;
  opacity:0;
  z-index:-1
}
.input-checkbox input:checked ~ .agree-box:before {
  width:7px;
  transition-delay:0ms
}
.input-checkbox input:checked ~ .agree-box::after {
  width:11px;
  transition-delay:180ms
}

uniapp如何利用单选框(radio)替代多选框(checkbox)

css代码画三角形箭头(上下左右)

使织梦DedeCMS默认编辑器变成所见即所得的方法

帝国cms功能之如何实现当前信息页高亮功能

标签: checkbox多选框, css代码

上面是“css美化input-checkbox多选框代码”的全面内容,想了解更多关于 前端知识 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_13713.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > 前端知识
本文共计2445个字,预计阅读时长17分钟
生活小工具,收录了80多款小工具
上一篇: 推荐一款免费开源的屏幕录制软件——OBS Studio
下一篇: 推荐一个高质量的图片素材网站——Unsplash
x 打工人ai神器