Extra unwanted space when adjusting CSS height and vertical scrolling

I have an element post

that can receive comments (which are appended to the bottom of the post).

I am doing a modal for my post, which is with HTML / CSS below. I would like to be able to add comments up to a certain height of the entire post (with comments), after which a scrollbar will appear.

HTML:

<div class="post-modal hidden"> 
  <span class="remove-modal glyphicon glyphicon-remove btn-sm"></span>
  <div class="post"> </div> <!-- Post is this div-->
</div>

      

CSS

.post-modal {
    position: fixed;
    width: 655px;
    height: 600px;
    right: 0;
    top: 75px;
    left: 289px;
    overflow-y: scroll;
}

      

Now my problem is that with the given height for the container .post-modal

div

, if the height of my post + comments is less than the height I set, then there is extra space at the bottom. However, the scrolling situation works if I keep adding comments until the height is reached / exceeded, since I set the scroll and height for the parent container.

How would you handle this without the extra space? Appreciate any suggestions!

+3


source to share


1 answer


You can install min-height

and max-height

to get rid of the extra space.



.post-modal {
    position: fixed;
    width: 655px;
    min-height: 100px;
    max-height: 600px;
    right: 0;
    top: 75px;
    left: 289px;
    overflow-y: scroll;
}

      

+4


source







All Articles