I am trying to achieve a layout where Element 1 and Element 2 can grow independently in height. However, I want the container's height to always match that of Element 2, while allowing Element 1 to grow as much as possible without exceeding the height of Element 2. If Element 1's height exceeds the container's height, it should get a scroll bar instead of making the container taller. Currently, I am using JavaScript to accomplish this but it feels inefficient. Is there a way to achieve this layout using CSS? Thank you.