1

I am trying to customise a radio button using two different images. One if not checked and one checked. The html is

<div class="form-group">
  <div class="radio">
    <label>
      <input type="radio" name="options" value="1"/>1
    </label>
  </div>
</div>

I'm trying o use the following css with no result.

.radio input[type=radio]:not(old){
  width   : 28px;
  margin  : 0;
  padding : 0;
  opacity : 0;
}

.radio input[type=radio]:not(old) {
  display      : inline-block;
  background   : url("../../images/empty-checks.png") no-repeat 0 0;
}

.radio input[type=radio]:not(old):checked{
  background-position : 0 -48px;
  background   : url("../../images/checks.png") no-repeat 0 0;
}

I would prefer a solution in which I will not have to modify my html.

1 Answers1

1

You have to disable the default markup of the radio input:

input[type=radio] {
  height: 28px;
  width: 28px;
  -webkit-appearance: none;
  -moz-appearance: none;
  -ms-appearance: none;
  -o-appearance: none;
  appearance: none;
  outline: none;
}

You also might want to use 1 image, as a sprite, instead of 2. http://vbl.su/i/checkbox.png

Check out this fiddle: https://jsfiddle.net/wietsedevries/gsz1bud4/3/

Wietse de Vries
  • 673
  • 7
  • 17
  • User wants check boxes not radio buttons, please fix, user does not want to make any modifications to html and certainly does not want to have to do it himself. – Adam Buchanan Smith Jun 01 '16 at 17:45