自定义复选框CheckBox的样式

简介: 自定义复选框CheckBox的样式

askjashdjk

1.<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
      /* Customize the label (the container) */
      .container {
        display: block;
        position: relative;
        padding-left: 35px;
        margin-bottom: 12px;
        cursor: pointer;
        font-size: 22px;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
      }
      /* Hide the browser's default checkbox */
      .container input {
        position: absolute;
        opacity: 0;
        cursor: pointer;
        height: 0;
        width: 0;
      }
      /* Create a custom checkbox */
      .checkmark {
        position: absolute;
        top: 0;
        left: 0;
        height: 25px;
        width: 25px;
        background-color: #eee;
      }
      /* On mouse-over, add a grey background color */
      .container:hover input ~ .checkmark {
        background-color: #ccc;
      }
      /* When the checkbox is checked, add a blue background */
      .container input:checked ~ .checkmark {
        background-color: #2196F3;
      }
      /* Create the checkmark/indicator (hidden when not checked) */
      .checkmark:after {
        content: "";
        position: absolute;
        display: none;
      }
      /* Show the checkmark when checked */
      .container input:checked ~ .checkmark:after {
        display: block;
      }
      /* Style the checkmark/indicator */
      .container .checkmark:after {
        left: 9px;
        top: 5px;
        width: 5px;
        height: 10px;
        border: solid white;
        border-width: 0 3px 3px 0;
        -webkit-transform: rotate(45deg);
        -ms-transform: rotate(45deg);
        transform: rotate(45deg);
      }
    </style>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <form>
    <label class="container">One
      <input type="checkbox" checked="checked" name="one" value="one"/>
      <span class="checkmark"></span>
    </label>
    <label class="container">Two
      <input type="checkbox" name="two" value="two" checked="checked"/>
      <span class="checkmark"></span>
    </label>
    <label class="container">Three
      <input type="checkbox" name="three" value="three"/>
      <span class="checkmark"></span>
    </label>
    <label class="container">Four
      <input type="checkbox" name="four" value="four"/>
      <span class="checkmark"></span>
    </label>
     <button type="submit">提交</button>
     </form>
  </body>
</html>

44.1.png

相关文章
|
7月前
全选或者单选checkbox的值动态添加到div
全选或者单选checkbox的值动态添加到div
31 0
|
7月前
复选框checkbox实现自定义样式
复选框checkbox实现自定义样式
37 1
|
7月前
layui的复选框怎么设置只能单选
layui的复选框怎么设置只能单选
|
7月前
|
前端开发
uniapp checkbox样式失效,选中框选中按钮不显示
uniapp checkbox样式失效,选中框选中按钮不显示
138 0
|
10月前
|
JavaScript 索引
jquery 获取或设置radio单选框选中值的方法
jquery 获取或设置radio单选框选中值的方法
510 0
|
11月前
|
JavaScript 前端开发
layui复选框checkbox全选和获取值的解决方案
layui复选框checkbox全选和获取值的解决方案
655 0
|
11月前
|
JavaScript
element checkbox复选框实现全选功能
element checkbox复选框实现全选功能
|
JavaScript
关于复选框checkbox没有选中不能获取值的问题
关于复选框checkbox没有选中不能获取值的问题
151 0
关于复选框checkbox没有选中不能获取值的问题
【Layui】关于单选框的选中状态,下拉框默认显示
【Layui】关于单选框的选中状态,下拉框默认显示
608 0
【Layui】关于单选框的选中状态,下拉框默认显示
CSS3自定义checkbox复选框
在线演示 本地下载
756 0