Auto height div with overflow and scroll when needed

后端 未结 10 2323
醉梦人生
醉梦人生 2020-12-08 06:45

I\'m trying to make a website with no vertical scrolling for a page, but i need that one of the DIVs i have to expand vertically to the bottom of the page (at most), and tha

10条回答
  •  [愿得一人]
    2020-12-08 07:06

    Try this:
    CSS:

    #content {
      margin: 0 auto;
      border: 1px solid red;
      width:800px;
      position:absolute;
      bottom:0px;
      top:0px;
      overflow:auto
    }
    

    HTML:

    
    
    ...content goes here...

    If you don't like absolute positioning in this case, just can play with making a parent and child div to this one, both with position:relative.

    EDIT: Below should work (I just put the css inline for the moment):

    ...content goes here...

提交回复
热议问题