【问题标题】:Is it possible to make click circle smaller for checkbox / radiobutton?是否可以使复选框/单选按钮的点击圈更小?
【发布时间】:2017-11-08 18:15:13
【问题描述】:

我想知道,在 Angular Material2 中,是否可以使选择圈变小?

当我尝试装箱时,圆形被切成矩形或正方形。示例:

【问题讨论】:

    标签: angular checkbox styles angular-material2


    【解决方案1】:

    HTML

    <div class="body">
          <h4><strong>Custom Radiobutton</strong></h4>
          <div class="radiobuttons">
             <div class="rdio rdio-primary radio-inline"> 
               <input name="radio" value="1" id="radio1" type="radio" checked>
               <label for="radio1">All</label>
             </div>
             <div class="rdio rdio-primary radio-inline">
               <input name="radio" value="2" id="radio2" type="radio">
               <label for="radio2">Select</label>
             </div>
         </div>
         <h4><strong>Custom Checkbox</strong></h4>
         <div class="cust-checkbox">
           <div class="custom-checkbox">
             <input name="noti_6" class="checkbox-custom" id="noti_6" value="6" type="checkbox">
             <label class="checkbox-custom-label" for="noti_6">Check me</label>
           </div>
         </div>
      </div>

    CSS

    .rdio {
        position: relative;
    }
    .rdio input[type="radio"] {
        opacity: 0;
    }
    .rdio label {
        padding-left: 10px;
        cursor: pointer;
        margin-bottom: 7px !important;
    }
    .rdio label:before {
        width: 18px;
        height: 18px;
        position: absolute;
        top: 1px;
        left: 0;
        content: '';
        display: inline-block;
        -moz-border-radius: 50px;
        -webkit-border-radius: 50px;
        border-radius: 50px;
        border: 1px solid #fbc52d;
        background: #fff;
    }
    .rdio input[type="radio"] {
        margin: 0px;
    }
    .rdio input[type="radio"]:disabled + label {
        color: #999;
    }
    .rdio input[type="radio"]:disabled + label:before {
        background-color: #fbc52d;
    }
    .rdio input[type="radio"]:checked + label::after {
        content: '';
        position: absolute;
        top: 5px;
        left: 4px;
        display: inline-block;
        font-size: 11px;
        width: 10px;
        height: 10px;
        background-color: #fbc52d;
        -moz-border-radius: 50px;
        -webkit-border-radius: 50px;
        border-radius: 50px;
    }
    .rdio-default input[type="radio"]:checked + label:before {
        border-color: #fbc52d;
    }
    .rdio-primary input[type="radio"]:checked + label:before {
        border-color: #fbc52d;
    }
    .rdio-primary input[type="radio"]:checked + label::after {
        background-color: #fbc52d;
    }
    .custom-checkbox > [type="checkbox"],
    .custom-checkbox label {
        /*margin-bottom:0px !important;*/
        
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    .custom-checkbox > [type="checkbox"]:not(:checked),
    .custom-checkbox > [type="checkbox"]:checked {
        position: absolute;
        left: -9999px;
    }
    .custom-checkbox > [type="checkbox"]:not(:checked) + label,
    .custom-checkbox > [type="checkbox"]:checked + label {
        position: relative;
        padding-left: 22px;
        cursor: pointer;
    }
    .custom-checkbox > [type="checkbox"]:not(:checked) + label:before,
    .custom-checkbox > [type="checkbox"]:checked + label:before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        margin-top: -9px;
        width: 17px;
        height: 17px;
        border: 1px solid #fbc52d;
        background: #ffffff;
        border-radius: 2px;
    }
    .custom-checkbox > [type="checkbox"]:not(:checked) + label:after,
    .custom-checkbox > [type="checkbox"]:checked + label:after {
        font: normal normal normal 12px/1 'Glyphicons Halflings';
        content: '\e013';
        position: absolute;
        top: 50%;
        margin-top: -7px;
        left: 2px;
        color: #fbc52d;
        xtransition: all .2s;
    }
    .custom-checkbox > [type="checkbox"]:not(:checked) + label:after {
        opacity: 0;
        transform: scale(0);
    }
    .custom-checkbox > [type="checkbox"]:checked + label:after {
        opacity: 1;
        transform: scale(1);
    }
    .custom-checkbox > [type="checkbox"][data-indeterminate] + label:after {
        content: '\2212';
        left: 2px;
        opacity: 1;
        transform: scale(1);
    }
    .custom-checkbox > [type="checkbox"]:disabled:not(:checked) + label:before {
        box-shadow: none;
        background-color: #eeeeee;
        border-color: #eeeeee;
        cursor: not-allowed;
        opacity: 1;
        color: #dadada;
    }
    .custom-checkbox > [type="checkbox"]:disabled:checked + label:before {
        box-shadow: none;
        background-color: #eeeeee;
        border-color: #eeeeee;
        cursor: not-allowed;
        opacity: 1;
        color: #fbc52d;
    }
    .custom-checkbox > [type="checkbox"]:disabled:checked + label:after {
        color: #fbc52d;
        cursor: not-allowed;
    }
    .custom-checkbox > [type="checkbox"]:disabled + label {
        color: #aaa;
        cursor: not-allowed;
    }
    .custom-checkbox > [type="checkbox"]:checked:focus + label:before,
    .custom-checkbox > [type="checkbox"]:not(:checked):focus + label:before {
        border: 1px solid #fbc52d;
        box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
    }
    .custom-checkbox label:hover:before {
        border: 1px solid #fbc52d !important;
    }
    .custom-checkbox [type="checkbox"]:disabled:not(:checked) + label:hover:before,
    .custom-checkbox [type="checkbox"]:disabled:checked + label:hover:before {
        border: 1px solid #fbc52d !important;
    }

    希望对你有帮助

    【讨论】:

    • 您好,谢谢您的回复。这不完全是我的想法。我不想让复选框变大。我只是想让点击时触发的cicle draw的效果更小。
    猜你喜欢
    • 2022-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-24
    • 1970-01-01
    • 1970-01-01
    • 2020-01-19
    • 2012-05-13
    相关资源
    最近更新 更多