Both elements can grow in height independently, however, I want the height of the container to always match the size of Element 2 while the height of Element 1 to grow in height as much as possible but never make the container grow past the height of Element 2. If the height of Element 1 is higher than the height of the container, Element 1 will get a scroll and not increase the size of the container.
I'm currently doing this in JavaScript in a really inefficient and I was wondering if I can maybe do this with CSS. Thank you.