Parallax design can be an engaging, creative way to visually enhance your website. But how do you implement it? This article will explore four distinct types of parallax scrolling methods, and how you can achieve each effect with 2 different methods:
Method 1: Manually add the effect by using HTML, CSS and JS code
Method 2: No coding required, by simply chatting with the PageGPT editor.
What is parallax and why use parallax?
Parallax scrolling is a web design technique where the background content moves at a slower pace than the foreground when you scroll. This creates an illusion of depth and can provide a more immersive, engaging user experience.
Parallax has several key benefits for your website. It can bring a unique, dynamic feel to your pages, helping to increase user engagement and improve SEO performance. Furthermore, it can enhance the user journey through your website, potentially leading to higher conversion rates.
In this article, we will walk through four distinct parallax examples you can incorporate into your own website. We’ll look at how you can achieve these effects both with and without code, using the PageGPT chat editor.
Slow Parallax
Slow parallax is the most common type of parallax effect. With this technique, the background moves slower than the foreground, enhancing the feeling of depth.
With Code
With CSS and Javascript, slow parallax is easy to implement. Here’s a simplified version of how you might do it. You will need to assign a “parallax-bg” class to your container that contains the background image. Then using the following javascript, you can control your background image to move at half the speed compared to your scrolling.
<div class="parallax-bg">
<!-- Foreground content goes here -->
</div>
window.addEventListener('scroll', function() {
var parallax = document.querySelector('.parallax-bg');
var scrollPosition = window.pageYOffset;
parallax.style.backgroundPosition = 'center ' + (scrollPosition * 0.5) + 'px';
});
with PageGPT
Creating all sorts of parallax effects with PageGPT is easy. You simply have to select your hero section and enter your requirements into the chat box.
In this example we’re using the prompt: “make the background image parallax”
We didn’t get what we wanted the first time, so we clicked on ‘no’ to let PageGPT it didn’t work. And viola! On the second time, it worked perfectly!
Static Parallax
Static parallax provides the illusion that the background image is not moving at all, also accentuating the depth effect.
with Code
Static Parallax is very easy to achieve, you don’t even need any javascript. With a few CSS tweaks, you can achieve a static parallax effect:
.parallax-static {
background-attachment: fixed;
}
with PageGPT
Once again, we can simply type into the chat box to let PageGPT know what we’re looking for. In this scenario we’re using this prompt: “make the background image have a parallax effect where it stays still”
On the first try it added a scroll parallax instead of a static one, so we let PageGPT know that it got it wrong. On its second try, we successfully added the static parallax effect!
Fast Parallax
Fast parallax, where the background moves faster than the foreground, creates a very dynamic and engaging visual effect.
with Code
To create a fast parallax effect with code, you’d use JavaScript to adjust the speed of the background image’s movement in response to scrolling.
window.addEventListener('scroll', function() {
var parallax = document.querySelector('.parallax-fast');
var scrollPosition = window.pageYOffset;
parallax.style.backgroundPosition = 'center ' + (scrollPosition * 1.5) + 'px';
});
with PageGPT
Let’s try this with PageGPT as well. Here we use the prompt: “make the background image have parallax effect that moves up faster than the foreground”
On the first try, It added a parallax effect that went down instead of up – so let’s go ahead to use the tweak feature. We simply tell it what to adjust: “make the parallax in the opposite direction”
Now we have our fast moving parallax, but there’s a slight issue, where the image is getting cropped off. We can simply tell PageGPT to fix it: “the image is getting cut off”
And just like that, we have our fast parallax effect, simply by chatting!
Zoom Parallax
A zoom parallax effect provides an immersive experience where the background image appears to zoom in as you scroll up.
with Code
Achieving a zoom parallax effect involves manipulating the scale of the background image based on the scroll position:
window.addEventListener('scroll', function() {
var parallax = document.querySelector('.parallax-zoom');
var scrollPosition = window.pageYOffset;
parallax.style.transform = 'scale(' + (1 + scrollPosition/1000) + ')';
});
with PageGPT
Once again, PageGPT simplifies the process. Here’s the prompt that we used: “make the background image have a parallax effect that zooms in as i scroll down”
Perfect! This time it works on the very first try. This effect doesn’t look very good on our cosmetics theme, however you can try to apply this zoom parallax on websites which have a more powerful theme.
BONUS: Cursor Parallax
A cursor parallax effect enhances interactivity by causing the background image to move slightly in response to the cursor movement.
with Code
This effect requires some JavaScript to track cursor position and adjust the background position accordingly:
document.addEventListener('mousemove', function(e) {
var parallax = document.querySelector('.parallax-cursor');
var posX = e.clientX/10;
var posY = e.clientY/10;
parallax.style.backgroundPosition = posX + 'px ' + posY + 'px';
});
with PageGPT
You guessed it! Simply type into the PageGPT chat box: “make the background image move slightly in the direction of my mouse”
Once again, PageGPT managed to apply the effect right away.
Conclusion
Parallax effects can bring depth, dynamism, and interactivity to your website, engaging your visitors and potentially increasing conversion rates. As we’ve seen, there are many different styles of parallax, each offering a unique visual experience.
Whether you’re comfortable diving into code or prefer a more user-friendly approach like PageGPT, there’s a way to bring parallax design to your website.
Even more effects
On top of parallax effects, you can add all sorts of other effects like website scroll animations, and other cool background animated effects. The possibilities are endless!
Don’t be afraid to experiment and see what works best for your audience and your design goals.