I am currently working on my website at and have implemented a "parallax-bg" class to create a parallax background effect.
Interestingly, the parallax effect is working flawlessly for the hero section at the top and the texture in the middle, but it's not functioning as expected for the contact section located at the bottom of the page.
The jQuery function I am using to achieve this effect is:
$(window).scroll(function() {
var scrolledY = $(window).scrollTop();
$('.parallax-bg').css('background-position', 'center ' + ((scrolledY) - 70) + 'px');
});
Additionally, the CSS styling specifically for the contact form section is:
section#contact{
background: linear-gradient(to bottom, rgba(0,0,0, 0.65) 0%,rgba(0,0,0, 0.65) 100%), url(https://www.shivampaw.com/images/bg-contact.jpg) no-repeat center -70px;
background-size: cover;
background-attachment: scroll;
color: white;
}
As for the hero section, the CSS code is as follows:
section#hero{
background: linear-gradient(to bottom, rgba(0,0,0, 0.65) 0%,rgba(0,0,0, 0.65) 100%), url(https://www.shivampaw.com/images/top-bg.jpg) no-repeat center -70px;
background-size: cover;
background-attachment: scroll;
text-align: center;
color: white;
font-weight: bold;
padding-bottom: 50px;
}
If anyone has any insights into why the parallax effect is not working as intended for the contact section, please let me know!
Thank you
Update: The term "parallax" refers to a fixed background effect which I have implemented using jQuery to ensure compatibility with mobile devices as well.