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>
  • 相关阅读:
    金融法规
    大型网站架构演化
    用一张决策图来重新思考你的网站
    互联网产品的一般商业模式
    怎样开始冥想
    创造安宁舒适工作日的17个办法
    人生规划和GTD——"知"、"得"与"合"
    立即行动的七个方法
    文件归档的学问
    入门GTD时间管理系统必读
  • 原文地址:https://www.cnblogs.com/rage-the-dream/p/6561981.html
Copyright © 2011-2022 走看看