I have three colored HTML div tags displayed inline-block like this:
Using only CSS, I want to respond with a media query such that the blue div actually rises over the red and green. The desired outcome will look like this:
I have composed the following HTML. As expected, my output is such that the blue div floats below the green and red. How can I stack blue on top by modifying my CSS in the above HTML?
<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: The height of the divs is dynamic, so modifying margins to force blue on top isn't really the solution I want.
EDIT: According to MDN, flex box is not supported in Safari. So flex box is not an option.