<html lang="en">
<head>
<link rel="stylesheet" href="./index.css">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="parallax-wrapper">
<div id="parallax-A" class="parallax">A</div>
<div id="parallax-B" class="parallax">B</div>
<div id="parallax-C" class="parallax">C</div>
</div>
</body>
</html>
html {
font-family: sans-serif;
font-size: 16px;
}
html, body {
padding: 0;
margin: 0;
height: 100%; /* Ensure body takes full height */
}
#parallax-wrapper {
height: 100vh;
overflow-x: hidden;
perspective: 1px; /* Adjust perspective value */
position: relative;
transform-style: preserve-3d;
}
.parallax {
position: absolute;
top: 0;
left: 0;
right: 0;
transform-style: preserve-3d; /* Ensure 3D context is maintained */
}
#parallax-A {
opacity: .5;
background: transparent;
height: 100rem;
z-index: 1; /* Layering for visibility */
}
#parallax-B {
background: skyblue;
opacity: .5;
height: 500px;
transform: translateZ(-.5px); /* Adjust transform and scale */
z-index: 2; /* Ensure it's above parallax-A */
}
#parallax-C {
display: block;
top: 300px;
opacity: .5;
background: greenyellow;
height: 500px;
z-index: 3; /* Ensure it's above parallax-A and B */
transform: translateZ(-1px); /* Adjust transform and scale */
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.