Dynamic height of sections inisde container. Fill height of divs inside the container

I have a container that either has one or three sections. Inside each sections I have table and there is list of rows inside the table. I want to make all the height of the sections dynamic such that it occupies the entire space. If there are more tables records inside the section than I need to add scroll to table to scroll records. But at all times the entire height should be filled inside the container. How can I have min and max-height for all sections.

Design scenario If there are 2 sections instead of 3: Red is container and blue are sections which contains table.

enter image description here

The structure

Container
      section1
        table
      section 2
        table
      section 3
        table