<section class="porto">
<div class="content-container flex-wrapper">
<div class="vertical-scroll-container">
<img src="https://marianabeldi.github.io/scroll-driven-sardinas/img/porto1.svg" alt="sardinas bajo en sodio">
<img src="https://marianabeldi.github.io/scroll-driven-sardinas/img/porto2.svg" alt="sardinas sin piel">
<img src="https://marianabeldi.github.io/scroll-driven-sardinas/img/porto3.svg" alt="sardinas en agua">
<img src="https://marianabeldi.github.io/scroll-driven-sardinas/img/porto4.svg" alt="sardinas al limon">
</div>
<div class="vertical-text">
<h2>Weird Fishes</h2>
<p>In the deepest ocean, the bottom of the sea. Your eyes, they turn me<br>
Why should I stay here? Why should I stay? I'd be crazy not to follow,
follow where you lead.</p>
<p>Your eyes,
they turn me turn me on to phantoms (way out).
I follow to the edge of the Earth (way out, way out). And fall off.</p>
<p>Yeah, everybody leaves if they get the chance and this is my chance.<br>
I get eaten by the worms and weird fishes. Picked over by the worm and weird fishes, weird fishes, weird fishes.</p>
<p>I'll hit the bottom, hit the bottom and escape. Escape. I'll hit the bottom, hit the bottom and escape.
Escape.</p>
</div>
</div>
</section>
*, *::before, *::after { box-sizing: border-box; }
body {
background-color: #3848a0;
font-family: "Open Sans", arial, sans-serif, system-ui;
margin: 0 auto;
}
.porto {
color: #f5dbc8;
padding: 32px;
text-align: center;
timeline-scope: --one, --two, --three, --four;
}
h2 {
line-height: 1;
text-transform: uppercase;
}
.porto p {
font-size: 1.1rem;
font-weight: 500;
letter-spacing: 0.03em;
max-width: 40ch;
}
.flex-wrapper {
align-items: center;
display: flex;
gap: 2rem;
}
.content-container {
margin-inline: auto;
width: 90vw;
}
.vertical-scroll-container {
align-items: center;
display: flex;
flex-direction: column;
flex: 1 1 50%;
gap: 6rem 0;
min-width: 400px;
overflow-y: scroll;
scrollbar-color: #3848a0 #1b2767;
scroll-snap-type: y mandatory;
padding: 200px 20px;
height: 400px;
}
.vertical-scroll-container img {
scroll-snap-align: center;
width: 400px;
/* animation: slideIn, slideOut; */
animation: slideInOut;
animation-timeline: view();
/* animation-range: entry, exit; */
}
@keyframes slideOut {
from {
transform: scale(1) translateY(0);
opacity: 1;
}
to {
transform: scale(.8) translateY(-100px);
opacity: 0
}
}
@keyframes slideIn {
from {
transform: scale(.8) translateY(100px);
opacity: 0;
}
to {
transform: scale(1) translateY(0);
opacity: 1;
}
}
/* target range in keyframes */
@keyframes slideInOut {
entry 0% {
transform: scale(.8) translateY(100px);
opacity: 0;
}
entry 100% {
transform: scale(1) translateY(0);
opacity: 1;
}
exit 0% {
transform: scale(1) translateY(0);
opacity: 1;
}
exit 100% {
transform: scale(.8) translateY(-100px);
opacity: 0
}
}
.vertical-text {
flex: 1 1 50%;
padding: 20px 0;
text-align: left;
}
.vertical-text p {
opacity: 0.2;
animation: light;
}
@keyframes light {
from { opacity: 0.2; }
to { opacity: 1}
}
/* view-timeline */
.vertical-scroll-container img:nth-of-type(1) { view-timeline: --one; }
.vertical-scroll-container img:nth-of-type(2) { view-timeline: --two; }
.vertical-scroll-container img:nth-of-type(3) { view-timeline: --three; }
.vertical-scroll-container img:nth-of-type(4) { view-timeline: --four; }
.vertical-text p:nth-of-type(1) { animation-timeline: --one; }
.vertical-text p:nth-of-type(2) { animation-timeline: --two; }
.vertical-text p:nth-of-type(3) { animation-timeline: --three; }
.vertical-text p:nth-of-type(4) { animation-timeline: --four; }
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.