Edit: Codepen with wireframe: https://codepen.io/djdmorrison/pen/RwNNpLb If I reduce the .container
width, the video becomes smaller as expected but keeps aspect ratio. However, if I reduce the .container
height, I want the video to become smaller (reduce width) to not overflow.
I've solved this with javascript but would rather a CSS solution.
I have the following wireframe:
This needs to be a single-page application - no scrolling. Header, chat sidebar, footer are all fixed sizes. The video description is a fixed height determined by its content. The video then takes up the remaining space, keeping a 16:9 aspect ratio. If the video height is small enough, then it 'sticks' to the bottom of the video and leaves any empty space below it. If the video height is large, then the video description should reach the bottom and the video should become smaller to fill the remaining space.
I've used the padding-top/bottom: 56.25%
trick to keep the video aspect ratio. This works well when the window is thin and tall enough. However, when the window is wide and short the video takes up the full remaining width, causing the height to increase and push the video description off the window.
The solution here is to set the video width so that it's at a size where the video description touches the bottom without falling off the page.
Psuedo code used for this (where videoContainer is the space for the video and description)
video.width = (videoContainer.height - videoDescription.height) * (16/9) + 'px'
This works well with javascript but I'd rather a CSS solution so I don't have to rely on event listeners to resize.
Thanks!