I have a table which is in a div. The length of the table can vary and I use the div to enforce a height.
<div id='CamListDiv'>
<table>
<thead>
<th><input type='checkbox' id='selectAll'/></th>
<th>Local Camera List</th>
</thead>
<tbody>
<tr><td>//camera 1 data //</td></tr>
<tr><td>...</td></tr>
<tr><td>//camera x data //</td></tr>
</tbody>
</table>
</div>
CSS
#CamListDiv {
height: 340px;
float: left;
overflow: auto;
overflow-y: hidden;
}
My problem is when the vertical scrollbar is needed, the space it occupies causes a horizontal scrollbar to appear.
I don't need the horizontal scrollbar and I tried to use the overflow-y: hidden;
css property to hide it but this causes both scrollbars to be hidden.
Does anyone know why overflow-y:hidden;
isn't working as expected or how to stop the horizontal scrollbar from being visible?
You are hiding the vertical scrollbar, and not the horizontal one.
Change overflow-y: hidden;
to overflow-x: hidden;
Heres a quick demo
I've added content surpassing the height, and a div
with a width greater than 340px inside #CamListDiv
. The content is only scrollable vertically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With