Smooth parallax. Parallax effect


Hi all. Today I’ll tell you about a small script for creating a simple parallax effect.

The article will be short but informative, so in about 15 minutes you will be able to add parallax to your landing page. If you have long wanted to add this interesting effect to your website, then read on...

What is the parallax effect on the site?

Let's first tell you what it is. So, the parallax effect in web design is a technique in which the background image moves slower than the elements that are above it. For those more experienced, I’ll make a reservation that we will not “bind” the parallax effect to the mouse cursor. Let's just create a parallax background. Let's get started.

How to make a parallax effect on a website

So, first of all, we connect the jquery library. As usual, between the head tags:

Now, you need to download and connect the Simple Parallax Scrolling script. I recommend using the compressed version right away, since there is no need to make additional settings inside the script:

Now, let's figure out what needs to be written on the html page for our parallax effect to work.

Smartlanding Landing page creation

Data-parallax="scroll"

Data-image-src="path to image/bg.png"

Please note that the image is not placed in the header using the img tag, but is set directly as an attribute in the container in which we want to implement parallax.

In principle, we can end here, but a few more words:

  • If there are no other elements in the dive in which we want to implement the parallax effect, then you need to set its height, otherwise you won’t see anything.
  • If you are using a non-responsive design, you can set the width and height of the image directly in html using the naturalWidth and naturalHeight attributes.
  • You can move images using the data-position attribute. This is analogous to background-position in css.

You can find other options on the official project page, which is listed above.

This article shows how to use CSS transformations and 3D manipulation to create a parallax effect on a website using pure CSS.

Parallax is almost always created using JavaScript and, most often, turns out to be resource-intensive, due to attaching listeners to the scroll event, directly modifying the DOM, and triggering unnecessary redraws and rearrangements. All this happens asynchronously with the thread in which the browser renders the page, which is why the scrolling starts to slow down and the picture breaks into pieces. Better parallax implementations track scrolling and use lazy DOM updates using requestAnimationFrame . The result is a qualitatively different one, but why not get rid of JavaScript altogether?

Moving the parallax effect to CSS saves you from performance problems and unnecessary manipulations, allowing the browser to regulate everything itself using hardware acceleration. As a result, almost all resource-intensive processes are handled directly by the browser engine. The frame rate (FPS) remains stable and the picture becomes smooth. Plus, you can immediately combine parallax with other CSS features - media queries or supports. Responsive parallax - what is it?

Theory Before we dive into understanding how this mechanism works, let’s create the necessary markup:

... ... ...
And basic styles:

Parallax ( perspective: 1px; height: 100vh; overflow-x: hidden; overflow-y: auto; ) .parallax__layer ( position: absolute; top: 0; right: 0; bottom: 0; left: 0; ) .parallax__layer- -base ( transform: translateZ(0); ) .parallax__layer--back ( transform: translateZ(-1px); )
All the magic happens in the parallax class. Defining the height and perspective style properties will set the element's perspective to its center, creating a fixed 3D viewport. overflow-y: auto will allow the content inside the element to scroll normally, while the element's descendants will be drawn relative to a fixed perspective. This is the key to creating the parallax effect.

Next, the parallax__layer class. As the name suggests, it defines the content layer to which the parallax effect will be applied. An element with this class is pulled out of the general flow of content and positioned to fill its container.

Finally, we have the parallax__layer--base and parallax__layer--back modifier classes. They are needed to regulate the scrolling speed of parallax elements, shifting them along the Z axis (removing them or bringing them closer to the viewport). For brevity, I made only two scroll speeds - we will add a few more later.

Depth Correction Since the parallax effect is created by 3D transformations, moving an element along the Z axis has the side effect of changing the size of the element depending on whether it is closer or further to the viewport. To fix this, we need to apply a scale() transformation so that the element is drawn at its original size:

Parallax__layer--back ( transform: translateZ(-1px) scale(2); )
The scaling coefficient can be calculated using the formula 1 + (translateZ * -1) / perspective) . For example, if the viewport perspective is set to 1px and we offset the element by -2px on the Z axis, then the factor will be scale(3) .

Parallax__layer--deep ( transform: translateZ(-2px) scale(3); )

Adjusting Layer Speed ​​Layer speed is controlled by a combination of perspective and Z offset values. Elements with negative Z values ​​will scroll slower than elements with positive Z values. The greater the difference between the value and 0, the more pronounced the parallax effect.
(i.e. translateZ(-10px) will scroll slower than translateZ(-1px)). Creating different sections of the parallax effect The previous examples demonstrated the basic technique of using simple content, but most parallax sites divide the page into different sections with different effects. Here's how to implement it in our method.

First, we need a parallax__group element to group our layers together:

... ... ...
the CSS for it would look like this:

Parallax__group ( position: relative; height: 100vh; transform-style: preserve-3d; )
In this example, I want each group to fill the viewport, so I specify height: 100vh , although the number for each group can be different if needed. transform-style: preserve-3d prevents the browser from flattening parallax__layer elements, and position: relative allows child parallax__layer elements to be positioned relative to their group.

An important rule to remember is that when grouping elements, we cannot trim the content inside the group, as overflow: hidden on the parallax__group element will break the entire parallax effect. Untrimmed content will cause child elements to protrude out of bounds. Therefore, you need to play around with the z-index value of the group to be sure that the content will be hidden and shown correctly as the user scrolls the site.

There are no hard or fast rules when it comes to working with layers, and different methods require different implementations. But to simplify debugging the positioning of layers, you can apply a simple transformation of group elements:

Parallax__group ( transform: translate3d(700px, 0, -800px) rotateY(30deg); )
Take a look at the following example and notice the debug checkbox!

Hello, dear blog readers. Today I want to tell you how to make parallax when scrolling a page using JQuery and CSS3.

To begin with, I would like to say that this effect really looks very effective. And it is very widely used on the foreign Internet. Thanks to this parallax, the effect of deepening and presence is created, so to speak. All this makes users visit this site more and more, just to admire its beauty.

You may remember that I showed several examples of such sites that use parallax when scrolling the page. If you missed this collection, be sure to check it out, it’s here.

Have you looked? Do you want it for yourself? :-) Let's create.

And so, let's go.

How it works?

Friends, as it turns out, there is nothing supernatural or difficult here. First, an HTML page is created. Then objects are created or drawn, for example in Photoshop. After everything has already been created, you need to immediately decide where which object will be located on the page, as well as at what speed it will scroll when the user scrolls the page.

Afterwards, using CSS, for example, three layers (maybe more) 1,2 and 3 are created. Next, ready-made objects are inserted onto each layer. These objects are given an exact position on the page in pixels. And then they set the scrolling speed for each layer. Usually the 1st layer (farthest) scrolls slower than the second and so on. Another important point is that a z-index is set for each layer. This parameter determines which object will be located behind which.

In other words, we get such a layered site :-) But it looks very beautiful.

HTML

First you need to create an HTML page:

Parallax when scrolling a page Example of parallax when scrolling

  • Cloudy with light rain View
  • Partly cloudy View
  • Thunderstorms View
  • That's all View
Cloudy, light rain

Here is an example of text to describe a weather forecast

Next Partly cloudy

Here we write the second example for partly cloudy weather

Prev Next Thunderstorms

Third example for thunderstorms

Prev Next That's all

This is an example of parallax when scrolling

Prev

As you can see, all objects on this page have already been assigned classes, which we will use later in styles. And we already have 3 layers here that have classes:

  • parallax-bg3 - the first layer, the top one.
  • parallax-bg2 - second layer, middle.
  • parallax-bg1 - and the third layer, the bottom one.

And ready-made drawings (objects) are already assigned to each of the three layers.

We also have text on the page that has standard scrolling. It also has a fixed position, but it scrolls along with the background. Although you can also set the scrolling speed for text, you need to create a separate fourth layer.

Between the tags and don’t forget to attach styles, as well as the parallax script itself:

Now comes the fun part.

CSS

First you need to remove all the padding on the edges of the page. This is done as follows:

Body ( background: url(../img/strange_bullseyes.png) repeat 100% 0; overflow-x: hidden; height: 4550px; line-height: 1.5; color: #000; font-size: 14px; font-family : Arial,sans-serif; )

We also set the background for the page here, it is in the source code, and we set the exact height for the page, it is 4550px.

Now for the #wrapper field where all our objects will be located, you need to set position: relative;. This way we show our drawings where our field is.

#wrapper ( position: relative; )

In this example we will use navigation through the so-called sections. It turns out to be a kind of large slider. The user has two options: click on the mark and it will automatically move to the specified location, or simply scroll the page in the usual way. In both cases it looks very nice.

And here is the navigation CSS code itself:

Nav#primary ( z-index: 5; position: fixed; top: 50%; right: 16px; margin-top: -40px; ) nav#primary li ( position: relative; height: 20px; ) nav#primary a ( display: block; width: 20px; height: 20px; text-indent: -9999px; background: transparent url("../img/nav-dot.png") 4px 4px no-repeat; ) nav#primary a:hover , nav#primary a.active ( background: transparent url("../img/nav-dot.png") 4px -16px no-repeat; ) nav#primary h1 ( position: absolute; right: 22px; top: - 7px; display: none; padding: 4px 20px 4px 7px;; color: #fff; white-space: nowrap; background: transparent url("../img/nav-arrow.png") 100% 50% no-repeat ; ) nav.next-prev ( margin: 20px 0 0 0; ) a.prev, a.next ( display: block; width: 15px; height: 11px; text-indent: -9999px; ) a.prev ( margin: 0 auto 5px auto; background: transparent url("../img/scroll-arrow-up.png") 0 0 no-repeat; ) a.prev:hover ( background: transparent url("../img/scroll -arrow-up.png") 0 -11px no-repeat; ) a.next ( margin: 5px auto 0 auto; background: transparent url("../img/scroll-arrow-down.png") -1px 0 no-repeat; ) a.next:hover ( background: transparent url("../img/scroll-arrow-down.png") -1px -11px no-repeat; )

Well, now let's move on to the layers themselves.

Text layer and its position:

#content ( z-index: 4; position: relative; max-width: 940px; padding: 0 10px; margin: 0 auto; line-height: 1.7; ) #content article ( width: 300px; ) #manned-flight , #frameless-parachute, #english-channel, #about ( padding-top: 105px; ) #manned-flight ( position: absolute; top: 0px; ) #frameless-parachute ( position: absolute; top: 1090px; ) #english -channel ( position: absolute; top: 2180px; ) #content h1 ( margin: 0 0 25px 0; font-size: 60px; font-family: Georgia, serif; font-weight: normal; line-height: 65px; ) #about ( position: absolute; top: 3270px; )

As you can see, the topmost text (#manned-flight) is set to an absolute position of 0 pixels, and the second text (#frameless-parachute) is set to a position of 1090px, which is significantly lower. Another important point: the content is set to z-index: 4; the topmost layer. This is done to prevent other layers from covering the text.

Now we will create layers from pictures:

The first layer is the largest clouds (#parallax-bg3):

#parallax-bg3 ( z-index: 3; position: fixed; left: 50%; top: 0; width: 940px; margin-left: -470px; ) #bg3-1 ( position: absolute; top: -111px; left: 355px; ) #bg3-2 ( position: absolute; top: 812px; left: 321px; ) #bg3-3 ( position: absolute; top: 1628px; left: 403px; ) #bg3-4 ( position: absolute; top: 2700px; left: -85px; )

Second layer of clouds:

#parallax-bg2 ( z-index: 2; position: fixed; left: 50%; top: 0; width: 1200px; margin-left: -600px; ) #bg2-1 ( position: absolute; top: 162px; left : 200px; ) #bg2-2 ( position: absolute; top: 300px; left: 1150px; ) #bg2-3 ( position: absolute; top: 543px; left: -35px; ) #bg2-4 ( position: absolute; top: 1180px; left: 250px; ) #bg2-5 ( position: absolute; top: 900px; left: 890px; )

And the third and last layer:

#parallax-bg1 ( z-index: 1; position: fixed; left: 50%; top: 0; width: 1200px; margin-left: -600px; ) #bg1-1 ( position: absolute; top: 85px; left : -270px; ) #bg1-2 ( position: absolute; top: 440px; left: 795px; ) #bg1-3 ( position: absolute; top: 900px; left: -220px; ) #bg1-4 ( position: absolute ; top: 1020px; left: 450px; )

Now let's see what our entire CSS file will look like from the sources:

Html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video ( margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; ) body ( line-height: 1; ) ol, ul ( list-style: none; ) blockquote, q ( quotes: none; ) blockquote:before, blockquote:after, q:before, q:after ( content: ""; content: none; ) table ( border -collapse: collapse; border-spacing: 0; ) /* General *********************************** ******************************/ html ( overflow-y: scroll; ) body ( background: url(../img /strange_bullseyes.png) repeat 100% 0; overflow-x: hidden; height: 4550px; line-height: 1.5; color: #000; font-size: 14px; font-family: Arial,sans-serif; ) h1 ( color: #333; ) a, a:link, a:active, a:visited ( -webkit-transition: color 0.25s ease-out; -moz-transition: color 0.25s ease-out; -o- transition: color 0.25s ease-out; transition: color 0.25s ease-out; color:#21a97e; outline: none; text-decoration:none; ) a:hover ( color:#000; ) img ( display:block; ) p ( margin:1em 0; ) /* Lines ************************************** ***************************/ hr ( margin: 0; border: none; border-top: 1px solid #3b3b3b; border-bottom : 1px solid #3b3b3b; height: 3px; ) /* Page structure *********************************** ******************************/ #wrapper ( position: relative; ) #branding ( width: 100%; background: # fff; ) #branding h1 ( width: 940px; padding: 10px 15px; margin: 0 auto; text-transform: uppercase; font-size: 18px; font-weight: bold; ) /* Navigation ******* **************************************** ********/ nav#primary ( z-index: 5; position: fixed; top: 50%; right: 16px; margin-top: -40px; ) nav#primary li ( position: relative; height: 20px; ) nav#primary a ( display: block; width: 20px; height: 20px; text-indent: -9999px; background: transparent url("../img/ nav-dot.png") 4px 4px no-repeat; ) nav#primary a:hover, nav#primary a.active ( background: transparent url("../img/nav-dot.png") 4px -16px no -repeat; ) nav#primary h1 ( position: absolute; right: 22px; top: -7px; display: none; padding: 4px 20px 4px 7px;; color: #fff; white-space: nowrap; background: transparent url( ". ./img/nav-arrow.png") 100% 50% no-repeat; ) nav.next-prev ( margin: 20px 0 0 0; ) a.prev, a.next ( display: block; width: 15px; height: 11px; text-indent: -9999px; ) a.prev ( margin: 0 auto 5px auto; background: transparent url("../img/scroll-arrow-up.png") 0 0 no-repeat; ) a.prev:hover ( background: transparent url("../img/scroll-arrow-up.png") 0 -11px no-repeat; ) a.next ( margin: 5px auto 0 auto; background: transparent url( "../img/scroll-arrow-down.png") -1px 0 no-repeat; ) a.next:hover ( background: transparent url("../img/scroll-arrow-down.png") - 1px -11px no-repeat; ) /* Parallax *************************************** **************************/ /* content */ #content ( z-index: 4; position: relative; max-width: 940px ; padding: 0 10px; margin: 0 auto; line-height: 1.7; ) #content article ( width: 300px; ) #manned-flight , #frameless-parachute, #english-channel, #about ( padding-top: 105px ; ) #manned-flight ( position: absolute; top: 0px; ) #frameless-parachute ( position: absolute; top: 1090px; ) #english-channel ( position: absolute; top: 2180px; ) #content h1 ( margin: 0 0 25px 0; font-size: 60px; font-family: Georgia, serif; font-weight: normal; line-height: 65px; ) #about ( position: absolute; top: 3270px; ) /* foreground (First, large clouds) */ #parallax-bg3 ( z-index: 3 ; position: fixed; left: 50%; top: 0; width: 940px; margin-left: -470px; ) #bg3-1 ( position: absolute; top: -111px; left: 355px; ) #bg3-2 ( position: absolute; top: 812px; left: 321px; ) #bg3-3 ( position: absolute; top: 1628px; left: 403px; ) #bg3-4 ( position: absolute; top: 2700px; left: -85px; ) /* midground (Clouds) */ #parallax-bg2 ( z-index: 2; position: fixed; left: 50%; top: 0; width: 1200px; margin-left: -600px; ) #bg2-1 ( position : absolute; top: 162px; left: 200px; ) #bg2-2 ( position: absolute; top: 300px; left: 1150px; ) #bg2-3 ( position: absolute; top: 543px; left: -35px; ) #bg2-4 ( position: absolute; top: 1180px; left: 250px; ) #bg2-5 ( position: absolute; top: 900px; left: 890px; ) /* background (Clouds) */ #parallax-bg1 ( z-index: 1; position: fixed; left: 50%; top: 0; width: 1200px; margin-left: -600px; ) #bg1-1 ( position: absolute; top: 85px; left: -270px; ) #bg1-2 ( position: absolute; top: 440px; left: 795px; ) #bg1-3 ( position: absolute; top: 900px; left: -220px; ) #bg1-4 ( position: absolute; top: 1020px; left: 450px; )

JQuery

And now we will set the scrolling speed for each layer layer, this is done as follows:

/* Layer scrolling speed */ function parallaxScroll())( var scrolled = $(window).scrollTop(); $("#parallax-bg1").css("top",(0-(scrolled*.25)) +"px"); $("#parallax-bg2").css("top",(0-(scrolled*.5))+"px"); $("#parallax-bg3").css( "top",(0-(scrolled*.75))+"px"); )

As you can see, the topmost layer of parallax-bg3 has the highest scrolling speed, the second layer has the lowest, and the last layer has the average speed.

Now this is what the script for the navigation itself looks like:

$("a.manned-flight").click(function())( $("html, body").animate(( scrollTop:0 ), 1000, function() ( parallaxScroll(); )); return false; )); $("a.frameless-parachute").click(function())( $("html, body").animate(( scrollTop:$("#frameless-parachute").offset().top ), 1000, function() ( parallaxScroll(); )); return false; )); $("a.english-channel").click(function())( $("html, body").animate(( scrollTop:$("#english-channel").offset().top ), 1000, function() ( parallaxScroll(); )); return false; )); $("a.about").click(function())( $("html, body").animate(( scrollTop:$("#about").offset().top ), 1000, function() ( parallaxScroll(); )); return false; ));

ι

That's basically all, friends. If you have any questions, ask in the comments. See you soon.

We create a parallax effect for large blocks with a background and for individual elements on the site.

Connect jQuery

$.stellar();

Parallax for elements

Setting the scroll speed for elements

We set the ratio relative to the standard scrolling speed.
Ratio 0.5 will cause the element to scroll at half speed,
ratio 1 will have no effect,
ratio 2 will cause the element to scroll at twice the speed.

If a coefficient less than 1 causes errors in the display of elements on the page, try setting position: fixed for this element; .

Parallax for background

If you want the background image to scroll as the page scrolls, then you need to add the following attribute:

As with element parallax, ratio is the ratio to standard scrolling.

For a coefficient less than 1, to avoid errors in displaying the background, it is better to set background-attachment to fixed .

On mobile phones, it is better not to use parallax for the background.

By the way, background-attachment: fixed on mobile phones may also not work due to the complexity of the calculations, so you need to set background-attachment: scroll for mobile phones (@media (max-width: 768px)).

Another clarification is that the background image must be larger in size than the height of the block in which it is used.

To prevent parallax from triggering on mobile devices (@media (max-width: 768px)), you can set the background-position property for the block: center center !important; .

When I tested horizontal parallax and Offsets, I had a lot of questions, but I put them aside for later and used this plugin only for vertical parallax.

There may be problems with IE due to background-attachment: fixed; – the background may move jerkily when scrolling.
You need to use separate conditions for IE:

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) ( .next-gen(background-attachment: scroll !important; background-position: 0 0 !important;) )

A primitive example for testing

Hic magnam eaque, mollitia delectus ullam cum possimus voluptatem. Et in commodi quam, consequatur magnam, dolorum odio tenetur, omnis possimus nihil suscipit. Earum quo, architecto laboriosam quisquam facilis fugit voluptates..png" alt="Sun" class="sun-1 sun" data-stellar-ratio=".4"> !}

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid corporis quo ducimus veniam debitis, blanditiis modi voluptatum laudantium nemo inventore veritatis cum, ex dolorem necessitatibus, quae quos nam, molestiae est.

Ea sint dolor nemo at dicta enim optio omnis molestias voluptatum rem, cumque provident ad eum. Delectus aperiam cumque, dolorum blanditiis, hic error quos reiciendis. Recusandae distinctio voluptas quidem ab!

Hic magnam eaque, mollitia delectus ullam cum possimus voluptatem. Et in commodi quam, consequatur magnam, dolorum odio tenetur, omnis possimus nihil suscipit. Earum quo, architecto laboriosam quisquam facilis fugit voluptates..png" alt="Sun" class="sun-2 sun" data-stellar-ratio="1.4"> !}

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquid corporis quo ducimus veniam debitis, blanditiis modi voluptatum laudantium nemo inventore veritatis cum, ex dolorem necessitatibus, quae quos nam, molestiae est.

Ea sint dolor nemo at dicta enim optio omnis molestias voluptatum rem, cumque provident ad eum. Delectus aperiam cumque, dolorum blanditiis, hic error quos reiciendis. Recusandae distinctio voluptas quidem ab!

Hic magnam eaque, mollitia delectus ullam cum possimus voluptatem. Et in commodi quam, consequatur magnam, dolorum odio tenetur, omnis possimus nihil suscipit. Earum quo, architecto laboriosam quisquam facilis fugit voluptates..png" alt="Sun" class="sun-3 sun" data-stellar-ratio="2"> 2017 !}

* ( margin: 0; padding: 0; border: 0; box-sizing: border-box; ) body ( font-size: 1em; font-family: sans-serif; ) div ( position: relative; width: 100% ; max-width: 1920px; margin: 0 auto; height: 600px; background-size: cover; z-index: 2; overflow: hidden; ) ..jpg) 50% 50% no-repeat; ) ..jpg) 50% 50% no-repeat; ) ..jpg) 50% 50% no-repeat; ) .block-text ( padding: 60px 30px; height: auto; font-size: 1.6em; line-height: 1.4; ) p ( position: relative; z-index: 2; max-width: 960px; margin: 0 auto; ) .sun ( position: absolute; z-index: 1; ) .sun-1 ( right: 0; top: 20%; ) .sun-2 ( left: 0; top: 20%; ) .sun- 3 ( left: 50%; margin-left: -200px; top: 20%; ) footer ( background-color: #000; color: #fff; text-align: center; padding: 20px 0; )

We connect the necessary libraries

The js/common.js file has this content:

$(function() ( // Parallax background // http://markdalgleish.com/projects/stellar.js/docs/ $.stellar(( responsive: false, horizontalScrolling: false, // it is necessary that there is no horizontal shift )); ));

Working example:

The parallax effect, also called parallax scrolling, is a special technique used primarily in computer graphics in which background images in perspective move more slowly than elements in the foreground. Today, this technique is very relevant and widespread in the field of web design. It used to be widely used in the gaming industry (10-15 years ago).

In recent years, parallax scrolling has been increasingly used in web design. The popularity of this approach began to grow since Nike updated the design of its website and used this idea. Below in the selection you can see this example.

This technology has caught on in the design field only because it looks really creative and cool. Despite its growing popularity, this effect can always be implemented in a special way and very successfully. Sometimes, when scrolling, the background image will also change, but this is not a requirement. The best part of this effect is that it consists of several layers of images that are “superimposed” on top of each other, and they all move at different speeds, which creates the effect of a three-dimensional space.

Although this effect is often used in this way, this does not mean that you are limited to creating an artificial three-dimensional effect. It can also be applied to various icons, images, and other elements on the page, which greatly increases the visitor's interaction with the site.

When they see this effect for the first time, they think that this effect is very interesting. But after they spend more time on a site that uses parallax, they realize that it is more than just “interesting.”

Performance issues

Although the effect looks great, it does have some downsides, such as performance issues. At the time when Nike was created using this effect, this was only possible through the use of javascript/jQuery, which significantly made the page heavier and slower its loading speed. But at the time, performance shortcomings were attributed to the excellent appearance of the site. This meant that the ease of use of the site was completely lost, as it loaded incredibly slowly. This became the biggest problem.

javascript is difficult to reproduce because the technology must control the placement of all elements on the page. Although this does not seem like such a difficult task, it is actually very difficult. javascript needs to carry out calculations for each pixel on a website page that is scrolled. Depending on the page scrolling speed, the number of calculations can reach 100 per second. And keep in mind that every element on the page is controlled by javascript at the same time that the calculations are performed. Not surprisingly, the parallax effect was not only difficult to develop, but also difficult to load if the Internet connection was slow.

Many developers do not recommend attaching this effect to more than 2 elements on the page. A few years ago, it was necessary to test pages on medium-power computers before launching them on the site.

New era technologies

Although this effect is not easy to engineer, there are various solutions. With the release of CSS3, creating parallax effects has become much easier.

The point is simple. All of your content is placed on one page, and navigation through the “sub-pages” is done using CSS3 transitions. In general, this is the principle of the good old anchor link technique, but this time it adds a transition to it. Below you can see a great example!

As you may have noticed, all content is located on the same page, and movement from one “page” to another occurs through a CSS3 transition. This is almost the same effect as parallax, but infinitely easier in terms of page load in the browser.

But there is still some difference here. As far as we know, it is almost impossible (or at least very difficult) to make elements on the same page move at different speeds using CSS3 transition. This means that the true parallax effect cannot be fully copied using CSS3 properties alone.

There is also another drawback here - CSS3 is not supported by some modern browsers. At least for now. This means that to create a full parallax effect you still need to use javascript.

javascript in action


This plugin allows you to bind the parallax effect to scrolling and mouse wheel using jQuery. This will allow you to make the background image or any other element on the page move at a different speed than the page scroll, creating the illusion of depth.


This plugin will allow you to easily create a parallax effect when scrolling web pages.


jParallax is described as a jQuery plugin that turns elements on a page into absolutely positioned layers that move in response to mouse movement. The layers move at different speeds, depending on their size.


This plugin is most suitable for your needs. It will help you create a similar parallax effect using preset paths. Even if it can’t be called very user-friendly in design, it will still make your page very attractive and interactive.

Educational articles on parallax scrolling

If you want to learn how to create a parallax effect yourself, then we have collected several educational articles for you.


: (Parallax scrolling with jQuery)


: (Developing a parallax scrolling platform)


: (Tutorial article on developing a website header animated in parallax style)


: Build a Parallax Scrolling Website Interface With jQuery and CSS()






2024 gtavrl.ru.