css checkbox code example

Example 1: checkbox input in css

//all checkbox
input[type="checkbox"]{
  box-shadow: 0 0 0 3px hotpink;
}

// all checked checkbox
input[type="checkbox"]:checked {
  box-shadow: 0 0 0 3px hotpink;
}

Example 2: custom checkbox with image css

<div>Check me!</div>
<input id="trigger" type="checkbox">
<label for="trigger" class="checker"></label>

Example 3: change on radio button

$('input[type=radio][name=bedStatus]').change(function() {
    if (this.value == 'allot') {
        alert("Allot Thai Gayo Bhai");
    }
    else if (this.value == 'transfer') {
        alert("Transfer Thai Gayo");
    }
});

Example 4: color checkbox css when clicked

input[type=checkbox]:checked {
  /*CSS after CHECKED*/
  color: #ffd369;
}

Example 5: custom checkbox in css

/* Custom CSS Checkbox */
<input type="checkbox">
<label>
  <span class="custom-checkbox"></span> my checkbox
</label>

[type="checkbox"] {
    opacity: 0;
    position: absolute;
}

.custom-checkbox {
    min-width: 0.75em;
    min-height: 0.75em;
    margin-right: 0.75em;
    border: 2px solid currentColor;
    border-radius: 50%;
    display: inline-block;
}

[type="checkbox"]:checked+label .custom-checkbox {
    border-color: blue;
    background: blue;
    box-shadow: inset 0 0 0 2px white;
}

Example 6: how to make html checkboxes

<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>

Tags:

Html Example