• CheckBox 设置背景色


    需要使用色 #ec6337(当然可以是任意颜色),解决问题:记住密码定制 CheckBox,解释全在注释里

    未选中

    选中

    主要使用到 ::before 或 ::after 伪类处理,伪装成内部的那个勾

    • html
    1.  
      <label>
    2.  
      <input type="checkbox" /> // 注意嵌在 label 里面
    3.  
      记住密码
    4.  
      <div class="show-box" /> // 注意嵌在 label 里面
    5.  
      </label>
    • CSS(LESS)
    1.  
      label {
    2.  
      position: relative;
    3.  
      cursor: pointer;
    4.  
       
    5.  
      input {
    6.  
      cursor: pointer;
    7.  
      }
    8.  
       
    9.  
      input:checked + .show-box {
    10.  
      background: #ec6337;
    11.  
      }
    12.  
       
    13.  
      .show-box {
    14.  
      position: absolute;
    15.  
      top: 0;
    16.  
      left: 0;
    17.  
      16px;
    18.  
      height: 16px;
    19.  
      border-radius: 2px;
    20.  
      border: 1px solid #d8d8d8;
    21.  
      background: white; // 这里取个巧,与下面颜色一样而已
    22.  
       
    23.  
      &:before { // 使用了 absolute 所以无所谓是 before 还是 after
    24.  
      content: ''; // 空白内容占位,当做盒模型处理,见下面
    25.  
      position: absolute;
    26.  
      top: 2px;
    27.  
      left: 6px;
    28.  
      3px; // 勾的短边
    29.  
      height: 8px; // 勾的长边
    30.  
      border: solid white; // 勾的颜色
    31.  
      border- 0 2px 2px 0; // 勾的宽度
    32.  
      transform: rotate(45deg); // 定制宽高加上旋转可以伪装内部的白色勾
    33.  
      }
    34.  
      }
  • 相关阅读:
    java内联函数
    jvm垃圾回收
    jvm内存管理
    java进程和线程的区别
    jvm
    简单易学的SSM(Spring+SpringMVC+MyBatis)整合
    Spring之声明式事务
    SpringMVC知识点小结
    Servlet之文件的上传与下载
    java使用字节流和字符流实现文件复制
  • 原文地址:https://www.cnblogs.com/developer-ios/p/14752426.html
Copyright © 2020-2023  润新知