純css實現checkbox樣式改變


<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>checkbox</title>
    <style>
        .checkbox input {
            display: none;
        }
        
        .checkbox input+label {
            background: url(./checkbox1.png) left center no-repeat;
            background-size: 20px 20px;
            padding-left: 20px;
        }
        
        .checkbox input:checked+label {
            background-image: url(./checkbox2.png);
        }
    </style>
</head>

<body>
    <div class="checkbox">
        <input type="checkbox" checked id="music" />
        <label for="music">音樂</label>
        <input type="checkbox" id="sport" />
        <label for="sport">運動</label>
    </div>
</body>

</html>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM