dmz社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 705|回复: 0

[Html/Css] checkbox 样式重写

[复制链接]
  • TA的每日心情

    2024-2-20 11:15
  • 签到天数: 11 天

    [LV.3]偶尔看看II

    878

    主题

    4343

    帖子

    3995

    积分

    终身会员[A]

    Rank: 7Rank: 7Rank: 7

    积分
    3995

    发表于 2020-3-25 22:00:02 | 显示全部楼层 |阅读模式

    本站资源全部免费,回复即可查看下载地址!

    您需要 登录 才可以下载或查看,没有帐号?立即注册

    x
    css样式

    [HTML] 纯文本查看 复制代码
    .me-checkbox:checked {
                background: #1673ff        
         }
    
            .me-checkbox {
                outline: none;/*轮廓*/
                width: 25px;
                height: 25px;
                background-color: #ffffff;
                border: solid 1px #dddddd;
                /* -webkit-border-radius:50%; */
                border-radius: 50%;
                font-size: 0.8rem;
                margin: 0;
                padding: 0;
                position: relative;
                display: inline-block;
                vertical-align: top;
                -webkit-appearance: button; /*让元素看的像一个button*/           
                -webkit-user-select: none;  /*让元素无法选择*/
                user-select: none;
                -webkit-transition: background-color ease 0.1s;
                transition: background-color ease 0.1s;
            }
    
            .me-checkbox:checked::after {/*这个是划勾*/
                content: '';
                top: 5px;
                left: 5px;
                position: absolute;
                background: transparent;
                border: #fff solid 2px;           
                border-top: none;
                border-right: none;            
                height: 6px;
                width: 10px;
                -moz-transform: rotate(-45deg);
                -ms-transform: rotate(-45deg);
                -webkit-transform: rotate(-45deg);
                transform: rotate(-45deg);
            }
            #ccc{
                outline:#00FF00 dotted thick;
                width: 25px;
                height: 25px;
                background-color: #ffffff;
                border: solid 1px #dddddd;
                /* -webkit-border-radius:50%; */
                border-radius: 50%;
                display: inline-block;
                -webkit-appearance: button;
            }
            #ccc:checked{
                background-color: green;
            }



    html样式
    [HTML] 纯文本查看 复制代码
    <input name-checkbox="checkbox" type="checkbox" class="me-checkbox ">
        <input name-checkbox="checkbox" type="checkbox" class="me-checkbox ">
        <input name-checkbox="checkbox" type="checkbox" class="me-checkbox ">
        <input type="checkbox"  name-checkbox="" id="ccc">
        <script >
            var d=document.querySelector("#ccc");
            d.onclick=function(){
               console.log(d.checked);
           }
        </script>




    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|小黑屋|本站代理|dmz社区

    GMT+8, 2025-2-2 04:42 , Processed in 0.087764 second(s), 34 queries .

    Powered by Discuz! X3.4 Licensed

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表