vertical scrolling bar for a table using html

前端 未结 2 581
刺人心
刺人心 2020-12-31 10:46

I want to fixe a height for my html table in the web page and if it pass the height automatically a vertical scrolling bar is shown.

please help.

相关标签:
2条回答
  • 2020-12-31 11:14

    It's not the table that scrolls, it is the div behind it.

    <div style="height:200px; overflow-y: scroll;">
      <table>
       ....
      </table>
    </div>
    

    use overflow-y if you only want a vertical scroll bar and overflow if you want both a vertical and horizontal.

    Note: setting an overflow attribute to scroll will always display the scrollbars. If you want the horizontal/vertical scrollbars to only show up when needed, use auto.

    0 讨论(0)
  • 2020-12-31 11:27

    You'd want to place the table inside of a div like so:

    <div style="height: 400px; overflow: auto;">
        <!-- Html Elements --!>
    </div>
    

    Anything inside that div, when it goes over 400px in height, will overflow and a scrollbar will be shown.

    0 讨论(0)
提交回复
热议问题