cssheightfancyboxfancybox-2

Div height according to content


I am working on a Modal with fixed header and footer.

Here is the Jsfiddle example

Currently the scrollable-stuff class height is 80%. If the content is less and there is no scrolling then i need to reduce the height and take the height of the content.

For example this example has a less content and there is no scroller but there is a empty space. I need to take the height of the content in case if there is no scrolling.

Any help or suggestion would be appreciated

Thanks in advace.


Solution

  • Instead of using height: 300px;

    you can use max-height: 300px;

    Because max-height tells the browser that the height can be less if the content is less but not greater than the specified height which in your case is 300px.