I've been experimenting with adding a parallax effect to the 'about us' page on my website. I successfully achieved the desired effect using pure CSS, but encountered an issue with an inner scrollbar appearing within the container
div.
PS. This is for a Magento store and unfortunately, I'm unable to modify the main
div.
Below is the HTML code:
<div class="container">
<div class="parallax-wrapper">
<div class="section parallax bg1"><span>Your Passion Is Our Passion!</span></div>
<div class="section static">
<p>Since more than 12 years ....</p>
</div>
<div class="section parallax bg2"><span>Large Choice Of Products</span></div>
<div class="section static">
<p>We are proud to offer you a large variety of products for every budget and taste.</p>
</div>
<div class="section parallax bg3"><span>Dedicated Customer Service</span></div>
<div class="section static">
<p>Our staff's only goal is to offer you a unique and professional experienxe.</p>
</div>
<div class="section parallax bg1"><span>Happy Shopping!</span></div>
</div>
</div>
And here is the CSS:
.parallax-wrapper{
height: 100vh;
overflow-x: hidden;
overflow-y: auto;
perspective: 2px;
}
.section{
position: relative;
height: 500px;
display: flex;
align-items: center;
justify-content: center;
color: white;
text-shadow: 0 0 5px #000;
}
.parallax::after{
content: " ";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: translateZ(-1px) scale(1.5);
background-size: 100%;
z-index: -1;
}
.static {
background: red;
height: 200px;
}
.bg1::after {
background-image: url(/app/design/frontend/TemplateMonster/md/web/images/bg1.jpg);
}
.bg2::after {
background-image: url(/app/design/frontend/TemplateMonster/md/web/images/bg2.jpg);
}
.bg3::after {
background-image: url(/app/design/frontend/TemplateMonster/md/web/images/bg3.jpg);
}
I aim for the parallax effect to occur when the user scrolls through the entire page, rather than the unintended inner scrollbar created by my code.