xxxxxxxxxx
/* HTML */
<input type="checkbox" id="myCheckbox">
/* CSS */
#myCheckbox {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
width: 20px;
height: 20px;
background-color: #ddd;
border: 1px solid #999;
border-radius: 2px;
}
#myCheckbox::before {
content: '';
display: inline-block;
width: 14px;
height: 14px;
margin-top: 2px;
margin-left: 2px;
background-color: #555;
border-radius: 1px;
visibility: hidden;
}
#myCheckbox:checked::before {
visibility: visible;
}
xxxxxxxxxx
input[type="checkbox"] {
-webkit-appearance: none; /* Remove default checkbox style on Safari */
-moz-appearance: none; /* Remove default checkbox style on Firefox */
appearance: none; /* Remove default checkbox style on other browsers */
width: 20px; /* Adjust the size of the checkbox */
height: 20px; /* Adjust the size of the checkbox */
border-radius: 4px; /* Add some border radius for a rounded look */
outline: none; /* Remove the highlight when focused */
transition: background-color 0.3s; /* Add a smooth transition effect */
}
input[type="checkbox"]::before {
content: "";
display: inline-block;
width: 20px; /* Adjust the size of the pseudo-element */
height: 20px; /* Adjust the size of the pseudo-element */
background-color: gray; /* Set the desired checkbox color */
border: 1px solid darkgray; /* Add a border for better visibility */
}
input[type="checkbox"]:checked::before {
background-color: green; /* Set the color when the checkbox is checked */
}
xxxxxxxxxx
input[type="checkbox"] {
/* Hide the default checkbox tick */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
/* Set the desired tick color */
background-color: red;
/* Add a custom tick symbol using a pseudo-element */
position: relative;
}
input[type="checkbox"]::before {
content: "";
display: inline-block;
position: absolute;
width: 10px;
height: 10px;
border: 2px solid white; /* Style the tick */
background-color: inherit;
top: 50%;
left: 50%;
transform: translate(-50%, -50%); /* Center the tick */
}
input[type="checkbox"]:checked::before {
background-color: green; /* Change the color of the tick when the checkbox is checked */
}
xxxxxxxxxx
input[type=checkbox] {
-moz-appearance:none;
-webkit-appearance:none;
-o-appearance:none;
outline: none;
content: none;
}
input[type=checkbox]:before {
font-family: "FontAwesome";
content: "\f00c";
font-size: 15px;
color: transparent !important;
background: #fef2e0;
display: block;
width: 15px;
height: 15px;
border: 1px solid black;
margin-right: 7px;
}
input[type=checkbox]:checked:before {
color: black !important;
}
xxxxxxxxxx
<!DOCTYPE html>
<html>
<head>
<style>
.main {
display: block;
position: relative;
padding-left: 45px;
margin-bottom: 15px;
cursor: pointer;
font-size: 20px;
}
/* Hide the default checkbox */
input[type=checkbox] {
visibility: hidden;
}
/* Creating a custom checkbox
based on demand */
.geekmark {
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: black;
}
/* Specify the background color to be
shown when hovering over checkbox */
.main:hover input ~ .geekmark {
background-color: yellow;
}
/* Specify the background color to be
shown when checkbox is active */
.main input:active ~ .geekmark {
background-color: red;
}
/* Specify the background color to be
shown when checkbox is checked */
.main input:checked ~ .geekmark {
background-color: green;
}
/* Checkmark to be shown in checkbox */
/* It is not be shown when not checked */
.geekmark:after {
content: "";
position: absolute;
display: none;
}
/* Display checkmark when checked */
.main input:checked ~ .geekmark:after {
display: block;
}
/* Styling the checkmark using webkit */
/* Rotated the rectangle by 45 degree and
showing only two border to make it look
like a tickmark */
.main .geekmark:after {
left: 8px;
bottom: 5px;
width: 6px;
height: 12px;
border: solid white;
border-width: 0 4px 4px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
</style>
</head>
<body>
<h1 style="color:green;">
Best Computer Science Platform
</h1>
<label class="main">CodeX
<input type="checkbox">
<span class="geekmark"></span>
</label>
<label class="main">GeeksforGeeks
<input type="checkbox" checked="checked">
<span class="geekmark"></span>
</label>
<label class="main">CodeY
<input type="checkbox">
<span class="geekmark"></span>
</label>
</body>
</html>