{"id":2462,"date":"2013-10-01T03:44:03","date_gmt":"2013-10-01T07:44:03","guid":{"rendered":"http:\/\/www.searchenginegenie.com\/web-design-blog\/?p=2462"},"modified":"2020-10-16T08:57:45","modified_gmt":"2020-10-16T12:57:45","slug":"an-easy-parallax-scrolling-method-2","status":"publish","type":"post","link":"https:\/\/www.searchenginegenie.com\/web-design-blog\/an-easy-parallax-scrolling-method-2\/","title":{"rendered":"An Easy Parallax Scrolling Method"},"content":{"rendered":"<p>Parallax scrolling is an exciting technique, where, as you scroll, the background image creates the illusion of 3D effect. Here the shortest and simplest b to achieve maximum tremendousness!<\/p>\n<h2>Step 1: Basic Method<\/h2>\n<p>I used the <b>&lt;section&gt;<\/b> tag with the attributes <b>data-type<\/b> &amp; <b>data-speed<\/b>, which were introduced in HTML5 coding and it makes the HTML markup easier to read.<\/p>\n<p>According to the condition for practice Data Attributes, any attribute that starts with <b>data-<\/b> will be treated as a storage area for private data. Additionally, this won\u2019t affect the layout or presentation.<\/p>\n<p><a name=\"imageclose-2463\"><div class=\"lb-album\"><a href=\"#image-2463\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2020\/10\/parallax-scrolling-section.jpg\" alt=\"parallax-scrolling-section\" class=\"alignleft size-full wp-image-2439\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2463\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2463\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/img-1.jpg\" alt=\"image-2463\">\r\n                   <\/div><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>To control the speed of the background images, we\u2019ll use <b>data-type=&#8221;background&#8221;<\/b>and <b>data-speed=&#8221;10&#8243;<\/b> as key attributes to specify the necessary parameters.<\/p>\n<p>Next, let\u2019s add the content within the <b>&lt;article&gt;<\/b> tag inside each <b>&lt;section&gt;<\/b><\/b><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a name=\"imageclose-2464\"><div class=\"lb-album\"><a href=\"#image-2464\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2020\/10\/parallax-scrolling-article.jpg\" alt=\"parallax-scrolling-article\" class=\"alignleft size-full wp-image-2440\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2464\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2464\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/img-2.jpg\" alt=\"image-2464\">\r\n                   <\/div><\/a><\/b><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>let\u2019s add the background images in our CSS for each section.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a name=\"imageclose-2465\"><div class=\"lb-album\"><a href=\"#image-2465\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2020\/10\/parallax-scrolling-background.jpg\" alt=\"parallax-scrolling-background\" class=\"alignleft size-full wp-image-2442\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2465\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2465\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/img-3.jpg\" alt=\"image-2465\">\r\n                   <\/div><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Upon adding backgrounds for both sections, it should look like:<\/p>\n<p><a name=\"imageclose-2466\"><div class=\"lb-album\"><a href=\"#image-2466\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/home-300x180.jpg\" alt=\"home\" class=\"alignleft\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2466\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2466\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/home.jpg\" alt=\"image-2466\">\r\n                   <\/div><\/a><\/b><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a name=\"imageclose-2467\"><div class=\"lb-album\"><a href=\"#image-2467\"><img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/about-300x180.jpg\" alt=\"about\" class=\"alignleft size-medium wp-image-2450\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2467\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2467\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/about.jpg\" alt=\"image-2467\">\r\n                   <\/div><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Let us add few more CSS to style to the page.<\/b><\/b><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a name=\"imageclose-2468\"><div class=\"lb-album\"><a href=\"#image-2468\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2020\/10\/parallax-scrolling-jquery.jpg\" alt=\"parallax-scrolling-jquery\" class=\"alignleft size-full wp-image-2443\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2468\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2468\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/img-4.jpg\" alt=\"image-2468\">\r\n                   <\/div><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 1.5em;\">Step 2:\u00a0<\/span><span style=\"font-size: 1.5em;\">jQuery code<\/span><\/p>\n<p>Yes, Using the jQuery code, we\u2019ll begin with the standard<b>document.ready()<\/b> method to ensure that the page has loaded and is ready to be manipulated.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Now, the first thing happening below is that we\u2019re iterating over each <b>&lt;section&gt;<\/b>in the page, which has the attribute <b>data-type=&#8221;background&#8221;<\/b><\/b><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a name=\"imageclose-2469\"><div class=\"lb-album\"><a href=\"#image-2469\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2020\/10\/parallax-scrolling-ready.jpg\" alt=\"parallax-scrolling-ready\" class=\"alignleft size-full wp-image-2445\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2469\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2469\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/img-6.jpg\" alt=\"image-2469\">\r\n                   <\/div><\/a><\/p>\n<p><a name=\"imageclose-2470\"><div class=\"lb-album\"><a href=\"#image-2470\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2020\/10\/parallax-scrolling-ready-func.jpg\" alt=\"parallax-scrolling-ready-func\" class=\"alignleft size-full wp-image-2444\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2470\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2470\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/img-5.jpg\" alt=\"image-2470\">\r\n                   <\/div><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Add another function, <b>.scroll()<\/b>, inside <b>.each()<\/b>, which is invoked as the user begins scrolling.<\/p>\n<p><a name=\"imageclose-2471\"><div class=\"lb-album\"><a href=\"#image-2471\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2020\/10\/parallax-scrolling-scroll.jpg\" alt=\"parallax-scrolling-scroll\" class=\"alignleft size-full wp-image-2446\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2471\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2471\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/img-7.jpg\" alt=\"image-2471\">\r\n                   <\/div><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>We need to determine how much the user scrolled up, and then divide the value by the <b>data-speed<\/b> value, mentioned in the step1.<\/p>\n<p><a name=\"imageclose-2472\"><div class=\"lb-album\"><a href=\"#image-2472\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2020\/10\/parallax-scrolling-ypos.jpg\" alt=\"parallax-scrolling-ypos\" class=\"alignleft size-full wp-image-2447\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2472\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2472\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/img-8.jpg\" alt=\"image-2472\">\r\n                   <\/div><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><b>$window.scrollTop()<\/b>: we are getting the current scroll value from the top. This initially determines how much the user has scrolled up. <b>$bgobj.data(&#8216;speed&#8217;)<\/b> refers to the <b>data-speed<\/b> assigned in the beginning, and <b>yPos<\/b> is the final value that we need to apply for scrolling. However, it will be a negative value, because we have to move the background in the opposite direction of the user\u2019s scroll.<\/p>\n<p><a name=\"imageclose-2473\"><div class=\"lb-album\"><a href=\"#image-2473\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2020\/10\/parallax-scrolling-pos.jpg\" alt=\"parallax-scrolling-pos\" class=\"alignleft size-full wp-image-2448\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2473\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2473\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/img-9.jpg\" alt=\"image-2473\">\r\n                   <\/div><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>The final thing that we need to do is put together our final background position into a variable. In order to keep the horizontal position of the background as static, we have assigned <b>50%<\/b> as its <b>xPosition<\/b>. Then, we added <b>yPos<\/b> as the <b>yPosition<\/b>, and, finally, assigned the background coordinates to our <b>&lt;section&gt;<\/b>background: <b>$bgobj.css({ backgroundPosition: coords });<\/b>.<\/p>\n<p>&nbsp;<\/p>\n<p>Your final b might look like:<\/p>\n<p><a name=\"imageclose-2474\"><div class=\"lb-album\"><a href=\"#image-2474\"><img src=\"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2020\/10\/parallax-scrolling-final.jpg\" alt=\"parallax-scrolling-final\" class=\"alignleft size-full wp-image-2441\"><span><\/span><\/a><\/div>              \r\n<a href=\"#imageclose-2474\" class=\"css3lightbox-close\">\r\n\t\t\t\t   <div class=\"lb-overlay\" id=\"image-2474\">\r\n                   <img src=\"http:\/\/www.searchenginegenie.com\/web-design-blog\/wp-content\/uploads\/2013\/10\/img-10.jpg\" alt=\"image-2474\">\r\n                   <\/div><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Yes, we have done it! Try it out by yourself.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Parallax scrolling is an exciting technique, where, as you scroll, the background image creates the illusion of 3D effect. Here the shortest and simplest b to achieve maximum tremendousness! Step 1: Basic Method I used the &lt;section&gt; tag with the attributes data-type &amp; data-speed, which were introduced in HTML5 coding and it makes the HTML [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[135,146],"class_list":["post-2462","post","type-post","status-publish","format-standard","hentry","category-whats-trending-web-design","tag-css-background-positioning","tag-html5-with-css"],"_links":{"self":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/2462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/comments?post=2462"}],"version-history":[{"count":74,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/2462\/revisions"}],"predecessor-version":[{"id":3908,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/posts\/2462\/revisions\/3908"}],"wp:attachment":[{"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/media?parent=2462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/categories?post=2462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.searchenginegenie.com\/web-design-blog\/wp-json\/wp\/v2\/tags?post=2462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}