Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define radio button size independently of screen resolution

I am formatting html radio buttons. I want to get something more or less like this (please ignore small font size and aligment) expected outcome

I did this by setting the width and height css properties of each individual button. Like for example here:

#r_starkeAblehnung.css-checkbox, #r_starkeZustimmung.css-checkbox {
border: 0px;
height: 50px; 
width: 50px;
}

This works when I look at my Chrome window with 75% zoom -which is my default for this page- but when I look at 100% zoom the radio buttons go back to all being small, and of equal size. They also lose their cool shading - I guess it has to do with a poorer resolution. The radio button dimensions are still there: my elements take up more space. But the radio buttons don't scale accordingly. I don't quite get what's going on.

I tried defining the radio button size in terms of em, but it didn't help.

For example, defining the three different sizes as 1em, 1.5em and 3em resulted in this:

Non-desided outcome

EDIT: jsfiddle, which has the same behaviour when changing the browser zoom

like image 718
elisa Avatar asked Sep 29 '15 10:09

elisa


1 Answers

You should just consider creating your own look/style for radio buttons. Something like this:

input[type=radio] {
  appearance: none;
  -moz-appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  outline: none;
  box-shadow: inset 0 0 0 2px #FFF;
  border: 2px solid #CCC;
}
input[type=radio]:checked {
  background-color: #CCC;
}
<input type="radio" name="radio" id="radio1" />
<label for="radio1">Radio 1</label>
<input type="radio" name="radio" id="radio2" />
<label for="radio2">Radio 2</label>
like image 130
orlland Avatar answered Sep 22 '22 13:09

orlland