DEV Community

spenglermanfred
spenglermanfred

Posted on

React + CSS - Set parent div to the same height as smaller child

I want to create a video player and a list of videos next to that with the exact same height as the player (see below) because I don't want any blank space next to the player.

My problem is, that if I'm making the window smaller, the parent div (which…

Top comments (4)

Collapse
 
thanhrossi profile image
Tran Thanh

You can use display: grid
jsfiddle.net/bo5wrsm4/2/

Collapse
 
spenglermanfred profile image
spenglermanfred

Thank you for your answer! It looks well with only 4 flexible video-list-items, however my problem is that if I'm adding more video list items (e.g. think if we have 30 videos in a playlist), and fixing the list item height to view a title and subtitle, the video list will overflow, and will push the player the same way.
My goal is to make the video list scrollable with unlimited items in it but still maintain the same height as in your example.

Collapse
 
thanhrossi profile image
Tran Thanh

you can wrap video-list-items with 1 div, and set max-height, overflow-y: auto

Thread Thread
 
spenglermanfred profile image
spenglermanfred

It doesn't work that way. jsfiddle.net/spenglermanfred/mb86d...