0

enter image description here

I want to create a checkbox like this. with a white tick and transparent background. Can someone help me on how to do it I tried
input[type="checkbox"]{ background-color:rgba(255,255,255,0.1); color:white; }
But doesnt work as in this codepen

R. Mani Selvam
  • 320
  • 8
  • 36

3 Answers3

2

you can use below css to get the same

working fiddle

input[type="checkbox"].hidden {
  display: none;
}

.demoCheck {
  border: 1px solid #ddd;
  width: 25px;
  height: 25px;
  display: block;
}

input[type="checkbox"]:checked.hidden + label {
  background: url(http://www.clipartsfree.net/vector/small/23493485345_Clipart_Free.png) center center no-repeat;
  background-size:cover;
}
<input type="checkbox" class="hidden" id="demo" >
<label for="demo" class="demoCheck demoCheckLabel"></label>
LKG
  • 4,152
  • 1
  • 11
  • 21
1

On Chrome, you'll need to overwrite the default browser settings like this.

input[type="checkbox"]{
    -webkit-appearance: none;
}

Here's a similar JS fiddle I made that might help you out.

https://jsfiddle.net/pappy/3eLduj2c/

alex
  • 1,042
  • 4
  • 18
  • 33
0
  1. please see this

HTML

 <div>
   <input id="option" type="checkbox" name="field" value="option">
    <label for="option"><span><span></span></span>Value</label>
 </div>

CSS

    input[type=checkbox]:not(old),
    input[type=radio   ]:not(old){
      width     : 2em;
      margin    : 0;
      padding   : 0;
      font-size : 1em;
      opacity   : 0;
    }
    input[type=checkbox]:not(old) + label,
    input[type=radio   ]:not(old) + label{
      display      : inline-block;
      margin-left  : -2em;
      line-height  : 1.5em;
    }
    input[type=checkbox]:not(old) + label > span,
    input[type=radio   ]:not(old) + label > span{
       display          : inline-block;
       width            : 0.875em;
       height           : 0.875em;
       margin           : 0.25em 0.5em 0.25em 0.25em;
       border           : 0.0625em solid rgb(192,192,192);
       border-radius    : 0.25em;
       background       : rgb(224,224,224);
       background-image :    -moz-linear-gradient(rgb(240,240,240),rgb(224,224,224));
       background-image :     -ms-linear-gradient(rgb(240,240,240),rgb(224,224,224));
       background-image :      -o-linear-gradient(rgb(240,240,240),rgb(224,224,224));
       background-image : -webkit-linear-gradient(rgb(240,240,240),rgb(224,224,224));
       background-image :         linear-gradient(rgb(240,240,240),rgb(224,224,224));
       vertical-align   : bottom;
    }

    input[type=checkbox]:not(old):checked + label > span,
    input[type=radio   ]:not(old):checked + label > span{
      background-image :    -moz-linear-gradient(rgb(224,224,224),rgb(240,240,240));
      background-image :     -ms-linear-gradient(rgb(224,224,224),rgb(240,240,240));
      background-image :      -o-linear-gradient(rgb(224,224,224),rgb(240,240,240));
      background-image : -webkit-linear-gradient(rgb(224,224,224),rgb(240,240,240));
      background-image :         linear-gradient(rgb(224,224,224),rgb(240,240,240));
    }
    input[type=checkbox]:not(old):checked + label > span:before{
      content     : '✓';
      display     : block;
      width       : 1em;
      color       : rgb(153,204,102);
      font-size   : 0.875em;
      line-height : 1em;
      text-align  : center;
      text-shadow : 0 0 0.0714em rgb(115,153,77);
      font-weight : bold;
     }
  1. Also check out here