I've made a checklist (which I guess would be similar to a single column List-View with the LVS_EX_CHECKBOXES extended style in Windows) using a div and inserting checkboxes in it with JS and associated label each on their own line. Each line would look like this
<label for="cb" style="white-space: nowrap;">Label<input type="checkbox" id="cb" /></label> I've set the width of the div to be auto so it automatically resizes based on the content and made sure the labels don't wrap on white spaces but that cause the div width to be smaller than the content forcing a horizontal scroll bar to appear.
Here's an example of the HTML code produced by the JS as reported by Firebug:
<div class="employees_list_column"> <div id="employees" class="check_list_wx" style="height: 130px; width: auto;"> <label style="white-space: nowrap" for="checklistwx_employees_35"> <input id="checklistwx_employees_35" type="checkbox" name="checklistwx_employees_35">E*** I***** </label> <br/> <label style="white-space: nowrap" for="checklistwx_employees_45"> <input id="checklistwx_employees_45" type="checkbox" name="checklistwx_employees_45">F*** P***** </label> <br/> <label style="white-space: nowrap" for="checklistwx_employees_34"> <input id="checklistwx_employees_34" type="checkbox" name="checklistwx_employees_34">J******* C*** </label> <br/> <label style="white-space: nowrap" for="checklistwx_employees_37"> <input id="checklistwx_employees_37" type="checkbox" name="checklistwx_employees_37">J****** M***** </label> <br/> <label style="white-space: nowrap" for="checklistwx_employees_1"> <input id="checklistwx_employees_1" type="checkbox" name="checklistwx_employees_1">L**** M*********** </label> <br/> <label style="white-space: nowrap" for="checklistwx_employees_2"> <input id="checklistwx_employees_2" type="checkbox" name="checklistwx_employees_2">M****** F******* </label> <br/> <label style="white-space: nowrap" for="checklistwx_employees_3"> <input id="checklistwx_employees_3" type="checkbox" name="checklistwx_employees_3">N*** A******* </label> <br/> <label style="white-space: nowrap" for="checklistwx_employees_4"> <input id="checklistwx_employees_4" type="checkbox" name="checklistwx_employees_4">O****** P******* </label> <br/> <label style="white-space: nowrap" for="checklistwx_employees_5"> <input id="checklistwx_employees_5" type="checkbox" name="checklistwx_employees_5">P*** T****** </label> <br/> </div> </div> And the CSS:
element.style { height: 230px; width: auto; } .check_list_wx { border: 1px solid #BBBBBB; margin: 10px; overflow: auto; } .employees_list_column { float: left; line-height: 24px; } Any ideas why the width of my div is smaller than the content?