UL or DIV vertical scrollbar
CssCss Problem Overview
I have problem with vertical scrollbar on my page. I have lot of items inside ul inside div, I tried with overflow:auto in style for div but it doesn't help. How to add scrollbar vertical to ul or div ?
<div id="content">
<p>some text</p>
<ul>
<li>text</li>
.....
<li>text</li>
</div>
Css Solutions
Solution 1 - Css
You need to define height of ul or your div and set overflow equals to auto as below:
<ul style="width: 300px; height: 200px; overflow: auto">
<li>text</li>
<li>text</li>
Solution 2 - Css
You need to set a height on the DIV. Otherwise it will keep expanding indefinitely.
Solution 3 - Css
Sometimes it is not eligible to set height to pixel values.
However, it is possible to show vertical scrollbar through setting height of div to 100%
and overflow
to auto
.
Let me show an example:
<div id="content" style="height: 100%; overflow: auto">
<p>some text</p>
<ul>
<li>text</li>
.....
<li>text</li>
</div>
Solution 4 - Css
this works for me :
<ul style="height: 100%; overflow: auto"
<li>text1</li>
....
<li>text100</li>
</ul>