Created
July 12, 2018 21:24
-
-
Save shshaw/24a8fbc755a3c2891291dc4e18d0f2a2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
.splitting-image img { width: 100%; display: block; } | |
@supports ( display: grid ) { | |
.splitting-image { | |
position: relative; | |
overflow: hidden; | |
background-size: cover; | |
visibility: hidden; | |
} | |
.split-container { | |
background: inherit; | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
display: grid; | |
grid-template: repeat( var(--row-total), 1fr ) / repeat( var(--col-total), 1fr ); | |
} | |
.split-cell { | |
background: inherit; | |
position: relative; | |
overflow: hidden; | |
} | |
.split-cell__inner { | |
background: inherit; | |
position: absolute; | |
visibility: visible; | |
/* Size to fit the whole container size */ | |
width: calc(100% * var(--col-total)); | |
height: calc(100% * var(--row-total)); | |
/* Position properly */ | |
left: calc(-100% * var(--col-index)); | |
top: calc(-100% * var(--row-index)); | |
} | |
/* Helper variables for advanced effects */ | |
.split-cell { | |
--center-x: calc((var(--col-total) - 1) / 2); | |
--center-y: calc((var(--row-total) - 1) / 2); | |
/* Offset from center, positive & negative */ | |
--offset-x: calc(var(--col-index) - var(--center-x)); | |
--offset-y: calc(var(--row-index) - var(--center-y)); | |
/* Absolute distance from center, only positive */ | |
--distance-x: calc( (var(--offset-x) * var(--offset-x)) / var(--center-x) ); | |
/* Absolute distance from center, only positive */ | |
--distance-y: calc( (var(--offset-y) * var(--offset-y)) / var(--center-y) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment