Created
July 18, 2024 11:40
-
-
Save shelane/3e4edcab3a4224266f54d56bae3bb011 to your computer and use it in GitHub Desktop.
Best CSS trick: instead of position relative + position absolute; use grid to overlay children
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.parent { display: grid; } | |
.child { grid-area: 1/1; } | |
Instead of: | |
.parent { position: relative } | |
.child { position: absolute; top: 0; left: 0; width: 100%; height: 100% } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment