I have two DIVs that I need to position exactly on top of each other. However, when I do that, the formatting gets all screwed up because the containing DIV acts like there
Here's some reusable css that will preserve the height of each element without using position: absolute:
position: absolute
.stack { display: grid; } .stack > * { grid-row: 1; grid-column: 1; }
The first element in your stack is the background, and the second is the foreground.
stack