【问题标题】:How to change size of checkbox and add border radius of icheck plugin?如何更改复选框的大小并添加 icheck 插件的边框半径?
【发布时间】:2020-01-08 08:25:17
【问题描述】:

我在我的项目中使用icheck。我想更改复选框的size 并将border-radius 添加到复选框。

我尝试了很多例子。

我的代码是:

<html>
<head>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.rawgit.com/bantikyan/icheck-bootstrap/master/icheck-bootstrap.min.css" rel="stylesheet">
    <style>
    .c-radius{
    border-radius:5px;
    }
    </style>
</head>
<body>
    <div class="checkbox icheck-primary">
        <input type="checkbox" checked id="primary" class="c-radius"/>
        <label for="primary">Keep username same as email id</label>
    </div>
</body>
</html>

【问题讨论】:

    标签: html css twitter-bootstrap bootstrap-4 icheck


    【解决方案1】:

    添加这个 CSS

    .icheck-primary[class*="icheck-"] > label {
        padding-left: 22px !important;
        line-height: 18px;
    }
    
    .icheck-primary[class*="icheck-"] > input:first-child + input[type="hidden"] + label::before, .icheck-primary[class*="icheck-"] > input:first-child + label::before {
        width: 18px;
        height: 18px;
        border-radius: 5px;
        margin-left: -22px;
    }
    
    .icheck-primary[class*="icheck-"] > input:first-child:checked + input[type="hidden"] + label::after,
    .icheck-primary[class*="icheck-"] > input:first-child:checked + label::after {
        top: 0px;
        width: 4px;
        height: 8px;
        left: 0px;
    }
    

    .icheck-primary[class*="icheck-"] > label{
      padding-left:22px !important;
      line-height: 18px;
    }
    .icheck-primary[class*="icheck-"] > input:first-child + input[type="hidden"] + label::before, .icheck-primary[class*="icheck-"] > input:first-child + label::before{
      width:18px;
      height:18px;
      border-radius:5px;
      margin-left:-22px;
    }
    
    .icheck-primary[class*="icheck-"] > input:first-child:checked + input[type="hidden"] + label::after, 
    .icheck-primary[class*="icheck-"] > input:first-child:checked + label::after{
      top:0px;
      width: 4px;
      height: 8px;
      left:0px;
    }
    <html>
    <head>
        <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
        <link href="https://cdn.rawgit.com/bantikyan/icheck-bootstrap/master/icheck-bootstrap.min.css" rel="stylesheet">
        <style>
        .c-radius{
        border-radius:5px;
        }
        </style>
    </head>
    <body>
        <div class="checkbox icheck-primary">
            <input type="checkbox" checked id="primary" class="c-radius"/>
            <label for="primary">Keep username same as email id</label>
        </div>
    </body>
    </html>

    【讨论】:

    • 如果可以更改大小并制作更小的复选框
    • 我们是否应该在不使用预定义类的情况下更改颜色
    • 为什么要使用库?,习惯于自定义css
    猜你喜欢
    • 1970-01-01
    • 2014-09-06
    • 1970-01-01
    • 2018-01-28
    • 2022-01-15
    • 2022-01-03
    • 1970-01-01
    • 2021-02-01
    • 2021-03-22
    相关资源
    最近更新 更多