I am trying to make the parent of a grid container to fit the grid container in the height, without defining it.
For example I have this pen, that the #header background is black.
It is only visible if I set for example the #header the height: 100vh (it is commented it out now)
I am trying to make the #header to adjust it’s height according to it’s child elements height.
You are floating your .container to the right of the header and floats are removed from the flow. Therefore the header actually contains no content at all which means there is no background.
If you contain the float the background will show.
However the black background still will not encompass the image on the right because you have set the grid row height to 310px and the image is around 450px tall and therefore pokes out of the section and is discounted from the flow of the document.
I don’t see why you need to float the container anyway as you are using css grid and get that position without floating. It also seems odd that you set a fixed height for the grid rows because you seldom want fixed heights on elements that hold fluid content.