首页 > 其他 > 详细

单选多选样式写法

时间:2018-12-14 12:25:38      阅读:141      评论:0      收藏:0      [点我收藏+]

动画多选样式

// html
<div id="box">
    <input type="checkbox" id="check" name="check" />
    <label for="check">Checkbox</label>
</div>

// css
input[type=checkbox]+label:before {
    height: 16px;
    line-height: 16px;
    width: 16px;
    border: 1px solid #000;
    display: inline-block;
    vertical-align: top;
    text-align: center;
    margin-right: 5px;
    content: "\2713";
    color: transparent;
    transition: color ease .3s;
}
input[type=checkbox]:checked+label:before {
    color: #000;
}

单选按钮样式

// html
<div id="box">
    <input type="radio" id="check" name="check" />
    <label for="check">Checkbox</label>
</div>
// css
input[type=radio] {
    display: none;
}
input[type=radio]+label:before {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 14px;
    text-align: center;
    vertical-align: top;
    margin-right: 20px;
    content: "\26AB";
    border: 1px solid #000;
    border-radius: 50%;
    font-size: 0;
    transition: font-size ease .3s;
}
input[type=radio]:checked+label:before {
    font-size: 12px;
}

参考

掘金-22个必备的CSS小技巧

单选多选样式写法

原文:https://www.cnblogs.com/bonly-ge/p/10118106.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!