Fork me on github

修改radio,checkbox默认样式

 

radio

 <input class="radio_type" type="radio" name="type" id="radio1" checked="checked" />
                                        <label for="radio1">radio1</label>
                                        <input class="radio_type" type="radio" name="type" id="radio2" />
                                        <label for="radio2">radio2</label>
复制代码
 label {
            line-height: 20px;
            display: inline-block;
            margin-left: 5px;
            margin-right: 15px;
            color: #777;
        }

        .radio_type {
            width: 20px;
            height: 20px;
            appearance: none;
            position: relative;
        }

            .radio_type:before {
                content: '';
                width: 20px;
                height: 20px;
                border: 1px solid #7d7d7d;
                display: inline-block;
                border-radius: 50%;
                vertical-align: middle;
            }

            .radio_type:checked:before {
                content: '';
                width: 20px;
                height: 20px;
                border: 1px solid rgb(117,94,143);
                background: rgb(117,94,143);
                display: inline-block;
                border-radius: 50%;
                vertical-align: middle;
            }

            .radio_type:checked:after {
                content: '';
                width: 10px;
                height: 5px;
                border: 2px solid white;
                border-top: transparent;
                border-right: transparent;
                text-align: center;
                display: block;
                position: absolute;
                top: 0;
                bottom: 0;
                left: 0;
                right: 0;
                margin: auto;
                vertical-align: middle;
                transform: rotate(-45deg);
            }
复制代码

 设置选中

$("#result_fall").prop("checked", true)

checkbox

 

复制代码
  <div style="height: 34px; padding-top: 7px; ">
                                                                             <label for="visibleLight">
                                                                                 <input type="checkbox" name="ImageOutput" value="visibleLight" id="visibleLight" checked>
                                                                                 <span class="checkbtn"></span>
                                                                                 <span class="checkboxLabel">可见光</span>
                                                                             </label>
                                                                             <label for="sticksPeople">
                                                                                 <input type="checkbox" name="ImageOutput" value="sticksPeople" id="sticksPeople">
                                                                                 <span class="checkbtn"></span>
                                                                                 <span class="checkboxLabel">火柴人</span>
                                                                             </label>
                                                                         </div>
复制代码
复制代码
 @*复选框*@
        input[type="checkbox"] {
            display: none;
        }

        .checkbtn {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 1px solid #dcdfe6;
            border-radius: 3px;
            position: relative;
        }

        input[type="checkbox"]:checked + span {
            background-color: rgb(117,94,144);
            border-color: rgb(117,94,144);
        }

        .checkbtn::after {
            content: '';
            width: 10px;
            height: 5px;
            border: 2px solid white;
            border-top: transparent;
            border-right: transparent;
            text-align: center;
            display: block;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            margin: auto;
            vertical-align: middle;
            transform: rotate(-45deg);
        }
        .checkboxLabel {
            font-size: 14px;
            font-weight: normal;
            vertical-align: top;
        }

        @*input[type="checkbox"]:checked + span::after {
            transform: rotate(45deg) scaleY(1);
        }*@
@*复选框*@
复制代码

获取值,设置值

 $("#visibleLight").prop("checked", true)
 $("[name='ImageOutput']").prop("checked", false)

 

posted @   我の前端日记  阅读(129)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
Copyright © 2021 LinCangHai
Powered by .NET 5.0 on Kubernetes
点击右上角即可分享
微信分享提示