当前位置: 移动技术网 > IT编程>网页制作>CSS > 9.使用CSS样式,自己制作单选框样式和选中功能

9.使用CSS样式,自己制作单选框样式和选中功能

2020年04月11日  | 移动技术网IT编程  | 我要评论

商场橱窗设计,小毅,陈绍基近况

自己制作单选框样式:

 

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>document</title>
    <!-- reset.css文件内容参考:https://www.cnblogs.com/lanshanxiao/p/12663192.html -->
    <link rel="stylesheet" href="./reset.css">
    <style>
        .radio-diy .radiocircle {
            width: 12px;
            height: 12px;
            border: 1px solid #999;
            border-radius: 50%;
            cursor: pointer;
            display: inline-block;
        }
        
        .radio-diy input:checked+span {
            border: 1px solid#008c8c;
        }

        .radio-diy input:checked~span {
            color: #008c8c;
        }

        .radio-diy input:checked+span.radiocircle::after {
            content: "";
            display: block;
            width: 6px;
            height: 6px;
            background: #008c8c;
            border-radius: 50%;
            cursor: pointer;
            margin-left: 3px;
            margin-top: 3px;
        }



        input[type="radio"] {
            display: none;
        }
    </style>
</head>

<body>
    请选择性别:
    <label class="radio-diy">
        <input type="radio" name="gender" value="male">
        <span class="radiocircle"></span>
        <span>男</span>
    </label>
    <label class="radio-diy">
        <input type="radio" name="gender" value="female">
        <span class="radiocircle"></span>
        <span>女</span>
    </label>
</body>

</html>

 

效果展示:

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网