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)
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:
EDIT: jsfiddle, which has the same behaviour when changing the browser zoom
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>
Try vertical-align: middle;
it may help
$("#questionAnswerRadio").css("display", "block");
#questionAnswerRadio {
vertical-align: middle;
padding: 0;
/*margin-bottom: 60px;*/
text-align: center;
display: none;
margin: auto;
}
#r_neutral.css-checkbox {
border: 0px;
height: 1em;
width: 1em;
vertical-align: middle;
margin: 0;
}
#r_ablehnung.css-checkbox, #r_zustimmung.css-checkbox {
border: 0px;
height: 1.5em;
vertical-align: middle;
width: 1.5em;
margin: 0;
}
#r_starkeAblehnung.css-checkbox, #r_starkeZustimmung.css-checkbox {
border: 0px;
height: 3em;
vertical-align: middle;
width: 3em;
margin: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<div id="questionAnswerRadio">
<label for="r_starkeAblehnung" class="css-label">
<input type="radio" id="r_starkeAblehnung" value="StarkeAblehnung" name="radio" class="css-checkbox"> <span>Starke Ablehnung</span>
</label>
<label for="r_ablehnung" class="css-label">
<input type="radio" id="r_ablehnung" value="Ablehnung" name="radio" class="css-checkbox"> <span>Ablehnung</span>
</label>
<label for="r_neutral" class="css-label">
<input type="radio" id="r_neutral" value="Neutral" name="radio" class="css-checkbox"> <span>Neutral</span>
</label>
<label for="r_zustimmung" class="css-label">
<input type="radio" id="r_zustimmung" value="Zustimmung" name="radio" class="css-checkbox"> <span>Zustimmung</span>
</label>
<label for="r_starkeZustimmung" class="css-label">
<input type="radio" id="r_starkeZustimmung" value="StarkeZustimmung" name="radio" class="css-checkbox"> <span>Starke Zustimmung</span>
</label>
</div>
I think the reason the em sizing doesn't work is because you havem't defined the base size for your text: the em size has nothing to define as'1' em.
adding
body {
font-size: 14px;
}
should keep the sizes constant on zoom.
链接地址: http://www.djcxy.com/p/88140.html上一篇: 如何将c ++代码制作成xcode库
下一篇: 定义与屏幕分辨率无关的单选按钮大小