css - Is there any way to make checkbox browser independent? -


is possible make checkboxs plain , consistent across browsers. means don't want browsers apply native style checkbox element.

also don't want use plugin replaces checkbox image , stuff.

is possible achieve overriding default css or something?

if understand right , can mimic checkbox this:

jsfiddle example

here i'm using font awesome present v symbol inside checkbox when checked.

first of hide real checkbox, define label , associate our checkbox using for="simplecheckbox" attribute of label, need in order able click on label focus , send real checkbox checked , using :before pseudo-element define our custom looking checkbox .

html:

<div class="visual-checkbox-container">         <input type="checkbox" class="simple-checkbox" name="simplecheckbox" id="simplecheckbox"  />         <label class="visual-checkbox" for="simplecheckbox">             check me if dare !         </label> </div> 

css:

.visual-checkbox-container {   margin: 20% 5%; }  .simple-checkbox {  display: none; }   .visual-checkbox {  width: 11em;  height: 50px;  position: relative;  display: inline-block;  padding: 1.5em 0 0 0; }    .visual-checkbox:before {  content: "";  position: absolute;  display: block;  left: 0;  top: 0;  border-radius: 25%;  box-shadow: .4px 1px 3px 0 rgba(154, 154, 154, 0.71) inset, -.5px -.4px 3px 0 rgba(154, 154, 154, 0.40) inset;  background-color: #fff;  width: 15px;  height: 15px;  }    .visual-checkbox:focus:before , .visual-checkbox:hover:before {  box-shadow: .5px .5px 2px 0 rgba(72, 217, 91, 0.70),  -.5px -.5px 2px 0 rgba(72, 217, 91, 0.70) , .2px .5px 3px 0 rgba(72, 217, 91, 0.90) inset, -.5px -.2px 3px 0 rgba(72, 217, 91, 0.90) inset;  }    .simple-checkbox:checked + .visual-checkbox:before {  box-shadow: .5px .5px 2px 0 rgba(72, 217, 91, 0.76),  -.5px -.5px 2px 0 rgba(72, 217, 91, 0.76);  background-color: rgba(78, 183, 91, 0.90); }  .simple-checkbox:checked + .visual-checkbox:after {  font-family:  fontawesome;  content: "\f00c";  position: absolute;  left: 0;  top: 0;  color:  #fff;  font-size: .9em;  } 

of course design done different .


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -