How to Create Bulb Checkbox With
HTML & CSS
Video Tutorial of Bulb Checkbox
Bulb Checkbox [Source Codes]
To Create Bulb Checkbox HTML and CSS, follow the given steps line by line:
Create a folder. You can name this folder whatever you want, and inside this folder, create the mentioned files.
Create an index.html file. The file name must be index and its extension .html
Create a style.css file. The file name must be style and its extension .css
Once you create these files, paste the given codes into the specified files. If you don’t want to do these then scroll down and download the source code by clicking download button.
First, paste the following codes into your index.html file
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>CSS Bulb</title>
- <link rel="stylesheet" href="style.css">
- </head>
- <body>
- <input type="checkbox" id="bulb" />
- <label for="bulb"></label>
- </body>
- </html>
Now paste the following codes into your style.css file
- * {
- padding: 0;
- margin: 0;
- box-sizing: border-box;
- }
- input[type="checkbox"] {
- appearance: none;
- position: absolute;
- display: block;
- height: 250px;
- width: 250px;
- background-color: #d0d5f4;
- transform: translate(-50%, -50%);
- top: calc(50% - 50px);
- left: 50%;
- border-radius: 50%;
- cursor: pointer;
- transition: 0.3s;
- }
- input[type="checkbox"]:before {
- position: absolute;
- content: "";
- height: 100px;
- width: 25px;
- background-color: #b4b9f1;
- bottom: 0;
- margin: auto;
- left: 0;
- right: 0;
- transition: 0.3s;
- }
- input[type="checkbox"]:after {
- position: absolute;
- content: "";
- height: 30px;
- width: 30px;
- border: 5px solid #b4b9f1;
- border-radius: 50%;
- margin: auto;
- left: 0;
- right: 0;
- bottom: 80px;
- transition: 0.3s;
- }
- label {
- position: absolute;
- height: 110px;
- width: 110px;
- background-color: #08475e;
- border-radius: 0 0 20px 20px;
- transform: translate(-50%, -50%);
- left: 50%;
- top: calc(50% + 120px);
- background: linear-gradient(#08475e 50%, #05303d 50%);
- cursor: pointer;
- }
- label:before {
- position: absolute;
- content: "";
- height: 50px;
- width: 50px;
- background-color: #05303d;
- bottom: -20px;
- margin: auto;
- left: 0;
- right: 0;
- border-radius: 50%;
- }
- label:after {
- position: absolute;
- content: "";
- height: 500px;
- width: 250px;
- background-color: rgba(255, 255, 255, 0.3);
- bottom: -50px;
- left: 55px;
- }
- input[type="checkbox"]:checked {
- background-color: #FCF529;
- box-shadow: 0 0 20px 10px rgba(252, 245, 41, 0.5);
- }
- input[type="checkbox"]:checked:before {
- background-color: #ff8e00;
- }
- input[type="checkbox"]:checked:after {
- border: 25px solid #ff8e00;
- }
-
If you face any difficulties while creating your Bulb Checkbox or your code is not working as expected, you can download the source code files by clicking on the download button.