JSFiddle - React, Tailwind, and code Playground
by Michel Penke
HTML
<script src="https://correctiv.org/assets/js/parallax-3d.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
initializeParallax(document.querySelector('.viewport'));
});
</script>
<style>html,
body {
height: 100%;
margin: 0;
font-family: "Yanone Kaffeesatz";
color: white;
font-size: 18px;
letter-spacing: 1.5px;
line-height: 1.5em;
}
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
h1 {
font-size: 4em;
}
.scene {
height: 150vh;
padding: 5vh 10vw;
}
.parallax {
background-size: cover;
-webkit-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
height: 130vh;
/* Since the parallax elements still consume space, we set the margin to undo
the height of this parallax element making it essentially consume 0 space.
*/
margin-bottom: -130vh;
}
p {
color: black;
margin: 1em 0;
z-index: 1;
position: relative;
}
.viewport {
height: 100%;
overflow-x: hidden;
overflow-y: auto;
position: relative;
-webkit-overflow-scrolling: touch;
}
.top,
.middle,
.bottom,
.left,
.center,
.right {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
}
.top {
-webkit-box-align: start;
-ms-flex-align: start;
-webkit-box-align: start;
align-items: flex-start;
}
.middle {
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.bottom {
-webkit-box-align: end;
-ms-flex-align: end;
align-items: flex-end;
}
.left {
-ms-flex-pack: left;
-webkit-box-pack: left;
justify-content: flex-start;
}
.center {
-ms-flex-pack: center;
-webkit-box-pack: center;
justify-content: center;
}
.right {
-ms-flex-pack: right;
-webkit-box-pack: right;
...