<section>
<div style="background:#CCFFFF">A</div>
<div style="background:#FFCCFF">B</div>
<div style="background:#FFFFCC">C</div>
<div style="background:#FFCCCC">D</div>
</section>
:root{
/*要素の数*/
--box_cont: 4;
}
@keyframes scroll_anim {
from {
transform: translate(0%, 0%);
}
to {
transform: translate(calc(-100% * calc(var(--box_cont) - 1)), 0%);
}
}
body {
height: calc(100svh * var(--box_cont));
}
section {
display: flex;
width: 100%;
overflow: hidden;
position: fixed;
top: 0;
left: 0;
}
section > div {
width: 100%;
height: 100svh;
font-size: 3rem;
font-weight: bold;
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
transform-origin: left;
animation: scroll_anim linear;
animation-timeline: scroll(root);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.