CSS-表單僞類選擇器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表單僞類選擇器</title>
    <style>
        form *:focus{
            /*background-color: pink;*/
        }
        form *:valid{
            /*background-color: green;*/
        }
        form *:invalid{
            /*background-color: red;*/
        }
        form *:required{
            background-color: blue;
        }
        form *:optional{
            background-color: yellow;
        }
        form *:default{
            outline: 1px solid red;
        }
        form *:checked{
            outline: 1px solid blue;
        }
    </style>
</head>
<body>
    <form action="">
        <input type="text">
        <input type="text" required>
        <br>
        <input type="tel" required pattern="\d{4}">
        <input type="radio" checked name="gender">
        <input type="radio" name="gender">
        <input type="radio" name="gender">
        <input type="radio" name="gender">
    </form>
</body>
</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章