Bootstrap

HTML+CSS 静态网页练习

文章目录


单选框

在这里插入图片描述

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>单选框</title>
    <script src="https://kit.fontawesome.com/59c20db7cc.js" crossorigin="anonymous"></script>
    <style>
        body {
            background-color: rgb(34, 34, 34);
        }
        
        .container {
            width: 500px;
            position: relative;
            margin: 0 auto;
        }
        
        h2,
        li {
            color: rgb(170, 170, 170);
        }
        
        .item {
            font-size: 20px;
            padding-top: 20px;
            padding-bottom: 30px;
            border-bottom: 1px solid rgb(51, 51, 51);
            transition: 0.2s all linear;
            list-style-type: none;
            display: flex;
            flex-direction: row-reverse;
            justify-content: flex-end;
        }
        
        .outer {
            width: 18px;
            height: 18px;
            border: 3.5px solid rgb(170, 170, 170);
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: 0.2s all linear;
        }
        
        .inner {
            width: 11px;
            height: 11px;
            background-color: rgb(170, 170, 170);
            border-radius: 50%;
            transition: 0.2s all linear;
            visibility: hidden;
        }
        
        .item:hover {
            color: #fff;
        }
        
        .item:hover .outer {
            border-color: #fff;
        }
        
        .item:hover .outer .inner {
            background-color: #fff;
        }
        
        .item input[type="radio"] {
            visibility: hidden;
        }
        
        .item input[type="radio"]+span {
            transition: 0.2s all linear;
            margin-left: 15px;
        }
        
        .item input[type="radio"]:checked+span {
            color: rgb(13, 255, 146);
        }
        
        .item input[type="radio"]~div {
            transition: 0.2s all linear;
        }
        
        .item input[type="radio"]:checked~div {
            border-color: rgb(13, 255, 146);
        }
        
        .item input[type="radio"]~div .inner {
            transition: 0.2s all linear;
        }
        
        .item input[type="radio"]:checked~div .inner {
            background-color: rgb(13, 255, 146);
            visibility: visible;
        }
        
        .footer {
            width: 200px;
            color: rgb(170, 170, 170);
            margin: 0 auto;
        }
    </style>
</head>

<body>
    <div class="container">
        <h2>Your favorite thing in the world:</h2>
        <ul>
            <label for="Pizza">
                <li class="item">
                    <input type="radio" id="Pizza" value="Pizza" name="food">
                    <span>Pizza</span>
                    <div class="outer">
                        <div class="inner"></div>
                    </div>
                </li>
            </label>

            <label for="Bacon">
                <li class="item">
                    <input type="radio" id="Bacon" value="Bacon" name="food">
                    <span>Bacon</span>
                    <div class="outer">
                        <div class="inner"></div>
                    </div>
                </li>
            </label>

            <label for="Cats">
                <li class="item">
                    <input type="radio" id="Cats" value="Cats" name="food">
                    <span>Cats</span>
                    <div class="outer">
                        <div class="inner"></div>
                    </div>
                </li>
            </label>
        </ul>
    </div>
    <div class="footer">
        Made By
        <i class="fa-solid fa-heart" style="font-size:15px;color:red;"></i> csu_yulin
        <i class="fa-solid fa-heart" style="font-size:15px;color:red;"></i>
    </div>
</body>

</html>
;