https://i.sstatic.net/bEC4Y.png
Is it possible to create a responsive layout with three divs that behave in the following way:
- When the viewport is narrow, the three divs stack on top of each other
- When the viewport is average, the first div spans full width at the top while the other two are side-by-side with equal height
- When the viewport is wide, all three divs appear side-by-side with equal height
I want a solution that works well across different browsers.
I have attempted various strategies using media queries:
- To achieve #1, I made each div
display:block
- For #2, I styled the green and blue divs as
display:table-cell
within a container div withdisplay:table
However, implementing a separate container div for all three elements with display:table
causes issues with the following approaches:
- Setting all divs to
display:table-cell
- due to interference between the red div and the others - Styling the red div and smaller container divs as
display:table-cell
- causing conflicts with the internal structure
It's a bit complicated to explain, but I hope you understand my problem. Any guidance is highly appreciated.
Thank you!
Edit: I prefer not to set the height of any div manually; it should adjust based on content