美文网首页
css 每天一练之模拟单选按钮

css 每天一练之模拟单选按钮

作者: 不要变成发抖的小喵喵喵喵喵喵 | 来源:发表于2017-05-10 11:19 被阅读0次
    效果图

    html结构

    <ul class="radioes">
        <li>
            <input type="radio" name="radio" id="radio1" checked>
            <label for="radio1"></label>
        </li>
        <li>
            <input type="radio" name="radio" id="radio2">
            <label for="radio2"></label>
        </li>
        <li>
            <input type="radio" name="radio" id="radio3">
            <label for="radio3"></label>
        </li>
        <li>
            <input type="radio" name="radio" id="radio4">
            <label for="radio4"></label>
        </li>
    </ul>
    

    css样式

    ul,li{
        list-style: none;
        margin: 0;
        padding: 0;
    }
    .radioes{
        margin: 100px auto;
    }
    .radioes li{
        float: left;
        margin: 0 10px;
    }
    .radioes input{
        display: none;
    }
    .radioes label{
        display: block;
        width: 100px;
        height: 50px;
        background-color: #ccc;
        border-radius: 50px;
        position: relative;
        transition: all ease .5s;
    }
    .radioes label:after{
        content: '';
        width: 48px;
        height: 48px;
        background-color: #fff;
        border-radius: 50%;
        position: absolute;
        left: 2px;
        top: 1px;
        transition: all ease .5s;
    }
    .radioes input:checked + label:after{
        left: 50px;
    }
    .radioes input:checked + label{
        background-color: #4ace55;
    }
    

    欢迎访问我的博客,同步发布
    感谢阅读,如有错误欢迎指正。

    相关文章

      网友评论

          本文标题:css 每天一练之模拟单选按钮

          本文链接:https://www.haomeiwen.com/subject/uagwtxtx.html