首頁 >web前端 >html教學 >html中單選框樣式自訂的範例

html中單選框樣式自訂的範例

黄舟
黄舟原創
2017-10-26 10:22:512531瀏覽

html中單選框樣式自訂的範例:

<!DOCTYPE html>
<html lang="en">
<head>
    <!--单选框样式-->
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        .choice{
            position: relative;
        }
        .choice .radio{
            position: relative;
            display: inline-block;
            font-weight: 400;
            color: #0c4757;
            padding-left: 25px;
            cursor: pointer;
        }
        .choice .radio input{
            position: absolute;
            left: -9999px;
        }
        .choice .radio i{
            display: block;
            position: absolute;
            top: 6px;
            left: 0;
            width: 15px;
            height: 15px;
            outline: 0;
            border: 1px solid #666;
            border-radius: 50%;
            transition: border-color .3s;
            -webkit-transition: border-color .3s;
        }
        .choice .radio input:checked+i{
            border-color: #0c4757;
        }
        .choice .radio input+i:after{
            position: absolute;
            content: &#39;&#39;;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background-color: red;
            opacity: 0;
            transition: opacity .1s;
            -webkit-transition: opacity .1s;
        }
        .choice .radio input:checked+i:after{
            opacity: 1;
        }
    </style>
</head>
<body>
<p class="choice">
    <label class="radio">在校生<input type="radio" name="radio" value="1" checked><i></i></label>
    <label class="radio">非在校生<input type="radio" value="2" name="radio"><i></i></label>
</p>
</body>
</html>

以上是html中單選框樣式自訂的範例的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
上一篇:HTML 底線標籤下一篇:HTML 底線標籤