Created
February 7, 2018 22:34
-
-
Save fribibb/cc8c3fc1081d60f8dcc69062fb6dc3e7 to your computer and use it in GitHub Desktop.
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
/* https://codepen.io/irksum/pen/qxbarb */ | |
@supports ( (--plx: 0) and (position: sticky) ) { | |
:root { | |
--plx-perspective: 1; | |
} | |
.parallax { | |
position: sticky; | |
width: 100vw; | |
height: 100vh; | |
overflow-x: hidden; | |
overflow-y: scroll; | |
transform-style: preserve-3d; | |
perspective: calc(var(--plx-perspective) * 1px); | |
perspective-origin: 0 0; | |
perspective-origin-x: 100%; | |
} | |
.parallax__child { | |
--plx-scale: calc(var(--plx-perspective) - var(--plx-z)); | |
transform: translateZ(calc(var(--plx-z) * 1px)) translateY(calc(50% - 50vh)) scale(var(--plx-scale)); | |
transform-origin: 0 0; | |
transform-origin-x: 100%; | |
} | |
.parallax__child--fast { | |
--plx-z: .3; | |
} | |
.parallax__child--slow { | |
--plx-z: -.3; | |
} | |
} | |
* { | |
box-sizing: border-box; | |
} | |
article { | |
padding: 15%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment