I am trying to style three colored HTML div tags displayed inline-block by using CSS only. The challenge I am facing is getting the blue div to appear on top of the red and green divs. My goal is to achieve a layout where the blue div overlaps the other two, visually stacking on top.
Here is the code snippet that I have put together. However, the current output shows the blue div below the green and red divs. How can I adjust my CSS within this code to make the blue div stack on top?
<html>
<head>
<style>
div { height: 10%; }
#red { width: 300px; background-color: red; display: inline-block; }
#green { width: 300px; background-color: green; display: inline-block; }
#blue { width: 300px; background-color: blue; display: inline-block; }
@media screen and (max-width: 940px) {
#red { width: 49%; }
#green { width: 49%; }
#blue { width: 100%; float: left; }
}
</style>
</head>
<body>
<div id="container">
<div id="red"></div>
<div id="green"></div>
<div id="blue"></div>
</div>
</body>
</html>
EDIT: It's worth noting that the height of the divs is dynamic, so adjusting margins to position the blue div on top might not be the ideal solution in this case.
EDIT: Flexbox, although a potential solution, is not supported in Safari as per MDN documentation. Therefore, I'm looking for an alternative method given this constraint.