UL or DIV vertical scrollbar

前端 未结 3 1959
孤城傲影
孤城傲影 2020-12-14 05:28

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 scr

相关标签:
3条回答
  • 2020-12-14 06:22

    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>
    
    0 讨论(0)
  • 2020-12-14 06:30

    You need to set a height on the DIV. Otherwise it will keep expanding indefinitely.

    0 讨论(0)
  • 2020-12-14 06:31

    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>
    
    0 讨论(0)
提交回复
热议问题