Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change the checkbox size using CSS?

Tags:

html

css

Is it possible to set the size of a checkbox using CSS or HTML across browsers?

width and size work in IE6+, but not with Firefox, where the checkbox stays 16x16 even if I set a smaller size.

like image 301
RaGE Avatar asked Nov 20 '08 21:11

RaGE


People also ask

How do I change a checkbox style in CSS?

The solution (in principle)Wrap your checkbox in a label element. This will mean that even when it is hidden, you can still toggle its checked state by clicking anywhere within the label. Hide your checkbox. Add a new element after the checkbox which you will style accordingly.

How can I increase checkbox?

The easiest way to increase the size of the checkbox is by using CSS width and height properties. Using these two properties we can easily set any custom width and height of the checkbox.

How do I select a check box in CSS?

just add the class="checkbox" to your checkboxes. Then create that style in your css code. You will still need to add the class for it to work in IE, and it will not work in other non-IE browsers that do not support IE.


2 Answers

It's a little ugly (due to the scaling up), but it works on most newer browsers:

input[type=checkbox]  {    /* Double-sized Checkboxes */    -ms-transform: scale(2); /* IE */    -moz-transform: scale(2); /* FF */    -webkit-transform: scale(2); /* Safari and Chrome */    -o-transform: scale(2); /* Opera */    transform: scale(2);    padding: 10px;  }    /* Might want to wrap a span around your checkbox text */  .checkboxtext  {    /* Checkbox text */    font-size: 110%;    display: inline;  }
<input  type="checkbox" name="optiona" id="opta" checked />  <span class="checkboxtext">    Option A  </span>  <input type="checkbox" name="optionb" id="optb" />  <span class="checkboxtext">    Option B  </span>  <input type="checkbox" name="optionc" id="optc" />  <span class="checkboxtext">    Option C  </span>
like image 130
jdw Avatar answered Oct 15 '22 04:10

jdw


Working solution for all modern browsers.

input[type=checkbox] {      transform: scale(1.5);  }
<label><input type="checkbox"> Test</label>

Compatibility:

  • IE: 10+
  • FF: 16+
  • Chrome: 36+
  • Safari: 9+
  • Opera: 23+
  • iOS Safari: 9.2+
  • Chrome for Android: 51+

Appearance:

  • Scaled checkboxes on Chrome, Win 10 Chrome 58 (May 2017), Windows 10
like image 44
Fellow Stranger Avatar answered Oct 15 '22 05:10

Fellow Stranger