You can't float, or otherwise move, option
elements with CSS or, so far as I'm aware, JavaScript. While this is impossible, why not instead use a nested ol
(or ul
...) to contain the elements that you want to display horizontally? For example:
<form action="#">
<fieldset>
<legend>Select some stuff</legend>
<fieldset>
<ol>
<li><label for="inputs1">label 1</label><input type="checkbox" name="inputs[]" id="inputs1" /></li>
<li><label for="inputs2">label 2</label><input type="checkbox" name="inputs[]" id="inputs2" /></li>
<!-- other stuff -->
<li><label for="inputs11">label 11</label><input type="checkbox" name="inputs[]" id="inputs11" /></li>
</ol>
</fieldset>
</fieldset>
</form>
With the CSS:
fieldset {
width: 50%;
margin: 0 auto 1em auto;
position: relative;
border: 1px solid #f90;
}
fieldset > fieldset {
width: 100%;
position: absolute;
left: -1px;
display: none;
}
fieldset:hover > fieldset,
fieldset > fieldset:hover {
display: block;
}
fieldset > fieldset > ol li {
float: left;
border: 1px solid #000;
padding: 0.2em;
width: 6em;
}
JS Fiddle demo.