Resizing a div to fit content with maximum height

后端 未结 3 1696
一向
一向 2021-02-07 20:01

I have a div with dynamic content. When the content loads in the div I want the div to resize to fit the content. But I want this resizing to have a maximum height. If the conte

相关标签:
3条回答
  • 2021-02-07 20:32

    You could do this with css, e.g.: max-height: 100px; overflow-y:scroll;

    0 讨论(0)
  • 2021-02-07 20:39

    Use:

    <div style="max-height: 400px; overflow-y:scroll; overflow-x: hidden">
    <p>Some dynamic content loads inside the div</p>
    </div>
    

    Then add: <div style="clear:both"></div> before closing the "div":

    <div style="max-height: 400px">
    <p>Some dynamic content loads inside the div</p>
    <div style="clear:both"></div>
    </div>
    
    0 讨论(0)
  • 2021-02-07 20:48
     div {height:auto;overflow:scroll;max-height:200px;}
    
    0 讨论(0)
提交回复
热议问题