zoukankan      html  css  js  c++  java
  • 美化checkbox

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
        .group .label {
            color: #aaa;
            font-size: 12px;
        }
        
        .group .button {
            background: #1161ee;
        }
        
        .group label .icon {
            width: 15px;
            height: 15px;
            border-radius: 2px;
            position: relative;
            display: inline-block;
            background: rgba(255, 255, 255, .1);
        }
        /*在文字前设置<span class="icon"></span>使用伪类,两个一样大小的直线,设置过度*/
        
        .group label .icon:before,
        .group label .icon:after {
            content: '';
            width: 10px;
            height: 2px;
            background: #fff;
            position: absolute;
            -webkit-transition: all .2s ease-in-out 0s;
            transition: all .2s ease-in-out 0s;
        }
        /*分别对before和after进行定位*/
        
        .group label .icon:before {
            left: 3px;
            width: 5px;
            bottom: 6px;
            -webkit-transform: scale(0) rotate(0);
            -ms-transform: scale(0) rotate(0);
            transform: scale(0) rotate(0);
        }
        
        .group label .icon:after {
            top: 6px;
            right: 0;
            -webkit-transform: scale(0) rotate(0);
            -ms-transform: scale(0) rotate(0);
            transform: scale(0) rotate(0);
        }
        /*当checkbox被选中时,改变选项文字所在label标签的颜色和span标签的背景色,并且使span的伪类进行
    旋转,使两个伪类组成对号形状*/
        
        .group .check:checked + label {
            color: #ff6700;
        }
        
        .group .check:checked + label .icon {
            background: #1161ee;
        }
        
        .group .check:checked + label .icon:before {
            -webkit-transform: scale(1) rotate(45deg);
            -ms-transform: scale(1) rotate(45deg);
            transform: scale(1) rotate(45deg);
        }
        
        .group .check:checked + label .icon:after {
            -webkit-transform: scale(1) rotate(-45deg);
            -ms-transform: scale(1) rotate(-45deg);
            transform: scale(1) rotate(-45deg);
        }
       .icon{
           border: 1px solid #1161ee;
       }
        </style>
    </head>
    
    <body>
        <div class="group">
            <input id="check" type="checkbox" class="check" checked style="display: none;" />
            <label for="check"><span class="icon"></span> 记住密码</label>
        </div>
    </body>
    
    </html>
  • 相关阅读:
    第十二周总结
    第十一周总结
    第十周总结
    人月神话阅读笔记04
    第九周总结
    第八周总结
    人月神话阅读笔记03
    主成分分析(PCA)算法介绍及matlab实现案例
    Cross-entropy
    压缩算法--TP(1978)
  • 原文地址:https://www.cnblogs.com/rage-the-dream/p/6561981.html
Copyright © 2011-2022 走看看