When creating applications, all of the moving parts have to come together to create a truly enjoyable end result experience for the user. But let’s face it, regardless of how intricate your backend might be, or all the wild and nifty things going on under the hood, if you don’t have something to grab the user’s attention at the outset, there’s less likelihood of them interacting for long, much less coming back for a return visit. These days there are almost an infinite amount of things you can do to create dynamic, experiential, impressive pages. And a lot of it actually depends not the user too —> where does the mouse go? Do the scroll all the way down? What do they click on? How long do they stay on each page/in each section before navigating somewhere else?
With scrolling, creativity abounds. Simply googling “great landing pages”, “awesome scrolling” or something of the link will return a myriad of fascinating (at times mind-boggling results). A popular (maybe sometimes over-used, according to different design blogs) is parallax scrolling. With parallax scrolling, you create the illusion of depth in a two-dimensional setting, by having elements positioned independently of one another or relative to something there than their parent. In the most basic parallax scroll, you’ll typically find some kind of container div which has a background image, color, etc. and perhaps some text. You would expect the two to move in sync with one another up the page as you scroll down. But then you scroll and they don’t move in conjunction at all! By setting a few properties, you can manipulate the background image to remain and/or slowly move while other elements continue appearing as the user scrolls down, creating that depth illusion.
<body> <section>
Out in the Galaxy
</section> <section>
Meteor Showers
</section> </body>
So your HTML may look something like the above where each section has a container holding the items, with different text and separate background images. Your CSS file then may look like:
html, body { height: 100%; width: 100%; margin: 0; padding: 0; } .container { background-attachment: fixed; background-position: center; background-repeat: no-repeat; background-size: cover; scroll-behavior: smooth; margin: 0; padding: 0; height: 150vh; position: relative; } #parallax-one { background-image: url('https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fwww.pixelstalk.net%2Fwp-content%2Fuploads%2F2016%2F04%2FStars-wallpapers-HD-backgrounds-download.jpg&f=1'); background-color: rgba(85, 143, 163, 0.34); } #parallax-two { background-image: url('https://il3.picdn.net/shutterstock/videos/6047102/thumb/1.jpg'); background-color: rgba(86, 126, 113, 0.34); } .text-overlay { color: white; background-color: inherit; z-index: 1; position: absolute; top: 50%; left: 50%; font-size: calc(2vh + 2vw); padding: 2vh 3vw 2vh 3vw; border-radius: 50px; }
The most important are the background-image specifications. Background-size is set to cover so that the image covers the entirety of the visible area, bg-repeat is set to no-repeat so that the image does not render multiple times in order to cover (relative to other specifications, center the background position and then lasty, andmaybe most importantly, background-attachment is set to fixed so that it will appear to stay in one place while the rest of the elements of the page continue moving up (instead of moving with them) e.g. “fixing the background to the page”.
With two separate ids for each container div, we are able to specify our different background images. We can also specify an overly color for the text. When the z-index is specified in the .text-overlay class, it will allow the background-color to show up for the text, but not over the image, which can be further manipulated to your heart’s content!
This is a super simple implementation and there are so many other things you can do with it (I may create a separate post later once I decide which specific things I want to highlight). With Javascript and/or jQuery (although there seems to be a trend to use jQuery less as many are moving away from it in light of the powerful JavaScript we have today), you can grab a user’s scroll position, and further manipulate your parallax scroll based on that. You can trigger a pop-up, which is especially useful for e-commerce sites trying to incite the viewer to buy, or for explanatory pages telling incredible stories that rely less on text and more on interactivity (check out Movement of Data), further cementing user engagement. There’s also numerous plugins, package, and frameworks that can advance the frontend look to something extraordinarily beyond (Rellax, ScrollMagic, Parallax.js, and Skrollr to name a few).
Happy scrolling!