I need to display four checkbox as following
A B
C D
There should be two in each line? Can anyone suggest what would be right css for this? They need to be inside or combination of Div
I need to display four checkbox as following
A B
C D
There should be two in each line? Can anyone suggest what would be right css for this? They need to be inside or combination of Div
If this is just a fixed file and doesn't need to be content-managed, I'd use columns for ease of use. If it needs to be content-managed and the content is likely to change then I'd go for dealing with rows.
HTML:
<html>
<div class="column one">
<div class="box A"></div>
<div class="box C"></div>
</div>
<div class="column two">
<div class="box B"></div>
<div class="box D"></div>
</div>
</html>
CSS:
div.column {
width:50%;
}
div.column.one {
float:left;
}
div.column.two {
float:right;
}
div.box {
width:40px;
height:40px;
}
<style>
.item {white-space: nowrap;display:inline; }
</style>
<fieldset>
<div class="item">
<input type="checkbox" id="a">
<label for="a">a</label>
</div>
<div class="item">
<input type="checkbox" id="b">
<label for="b">b</label>
</div>
<br/> //link break or anything you like
<div class="item">
<input type="checkbox" id="c">
<label for="c">c</label>
</div>
<div class="item">
<input type="checkbox" id="c">
<label for="c">D</label>
</div>
</fieldset>
This should work for you with slight minor changes if you feel. Thanks.
One of possible solutions is to put the checkbox inside the label tag
<label for="cb1"><input id="cb1" name="cb1" type="checkbox" /> checkbox1 </label>
<label for="cb2"><input id="cb2" name="cb2" type="checkbox" /> checkbox2 </label>
<label for="cb3"><input id="cb3" name="cb3" type="checkbox" /> checkbox3 </label>
<label for="cb4"><input id="cb4" name="cb4" type="checkbox" /> checkbox4 </label>
and stylize it as follows
label {
display:block;
width:50%;
*width:49%; /*for IE7 only*/
float:left;
}
label[for="cb3"] {
clear:left;
}
Thanks to Liam for calling attention to this SO question: Should I put input tag inside label tag?.
Now the answer is compatible with screenreaders and IE7.