Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML/CSS: how can I make the checkboxes grow when zooming in and shrink when zooming out?

Tags:

html

css

checkbox

I have this simple code for testing:

<html>
<head>
<style type="text/css">
    ul{
        float:left;
        margin:0;
        list-style:none;
        padding:0;
      }
</style>
    </head>
<body>
    <ul>
       <li><input type="checkbox" id="c1" class="checkBox">a</li>
        <li><input type="checkbox" id="c2" class="checkBox"/>b</li>
        <li><input type="checkbox" id="c3" class="checkBox"/>c</li>
    </ul>
    <ul>
        <li><input type="checkbox" id="c4" class="checkBox"/>d</li>
        <li><input type="checkbox" id="c5" class="checkBox"/>e</li>
           <li><input type="checkbox" id="c6" class="checkBox" />f</li>
    </ul>
    <ul>
        <li><input type="checkbox" id="c7" class="checkBox"/>g</li>
        <li><input type="checkbox" id="c8" class="checkBox"/>h</li>
        <li><input type="checkbox" id="c9" class="checkBox"/>i</li>
    </ul>
</body>
</html>

here is the result:

enter image description here

but if I zoom out the text gets smaller but the checkboxes remain the same

enter image description here

and if I zoom in the text gets bigger but the checkboxes remain the same

enter image description here

is it possible to make it so that the checkboxes would change their size as well? for example proportionally to the size of their label? thanks in advance

like image 473
ksm001 Avatar asked Dec 08 '12 15:12

ksm001


3 Answers

jsFiddle DEMO

Use CSS3 to zoom the list as well as the browser rendered checkboxes!

.extraLarge ul {
  -moz-transform: scale(1.50);
  -webkit-transform: scale(1.50);
  -o-transform: scale(1.50);
  transform: scale(1.50);
  padding: 10px;
}
like image 128
arttronics Avatar answered Oct 10 '22 15:10

arttronics


You can do it with CSS3 a by using the :checked selector. What this does is use a styled input with a background image. So when you zoom in/out, it will re-size, along with the text. Unfortunately, it doesn't work in IE9 and under.

CSS:

.theCheckbox input {
    display: none;
}

.theCheckbox span {
    width: 20px;
    height: 20px;
    display: block;
    background: url("link_to_image");
}

.theCheckbox input:checked + span {
    background: url("link_to_checked_image");
}

HTML:

<label for="test">Label for checkbox</label>
<label class="theCheckbox">
    <input type="checkbox" name="test"/>
    <span></span>
</label>
like image 27
DaKoder Avatar answered Oct 10 '22 16:10

DaKoder


You could create your own checkbox control, so that you would not rely on the native OS implementation. When you create it using common html elements then browser zoom will work smoothly.

There are plenty of existing plugins for libraries (like jQuery)

like image 29
Tx3 Avatar answered Oct 10 '22 16:10

Tx3