A Pen by Daniel Schwarz on CodePen.
Created
May 22, 2023 10:38
-
-
Save frontalex/e05b8da99481cdd46b32e4decf817c7a to your computer and use it in GitHub Desktop.
CSS Grid animation #2: expanding columns
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
<div id="grid"> | |
<div class="left"></div> | |
<div class="center"></div> | |
<div class="right"></div> | |
</div> |
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
body { | |
margin: 0; | |
} | |
#grid { | |
height: 100vh; | |
transition: 500ms; | |
display: grid; | |
grid-template-columns: 1fr 1fr 1fr; | |
gap: 3px; | |
background: crimson; | |
} | |
:where(.left, .center, .right) { | |
background: navajowhite; | |
transition: 300ms; | |
} | |
:where(.left, .center, .right):hover { | |
background: crimson; | |
} | |
#grid:has(.left:hover) { | |
grid-template-columns: 2fr 0.5fr 0.5fr; | |
} | |
#grid:has(.center:hover) { | |
grid-template-columns: 0.5fr 2fr 0.5fr; | |
} | |
#grid:has(.right:hover) { | |
grid-template-columns: 0.5fr 0.5fr 2fr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment