different positions. Parallax motion, or in our case, parallax scrolling, then gives us the illusion that two objects in the same line of sight, but with distance between them, seem to move at different speeds. If you've ever looked out a car window while driving at 100 km per hour down a highway, you'll notice that the electricity poles seem to zip by at a high pace, while the mountains in the background seem to move by really slowly, almost at a standstill. This is parallax motion in action.
As far as the web goes, we can induce a parallax effect on containers that have background images and text above them. In its simplest form, parallax scrolling will cause the content to scroll as normal, and the background to remain stationary. The beauty about this technique in its simplest form is that it only requires CSS. Let's dig in.
Parallax Scrolling egs:
http://keithclark.co.uk/articles/pure-css-parallax-websites/---(css-paralax link)
Below is a sample HTML markup for the Pure CSS Parallax Scrolling:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
body, html { | |
height: 100%; | |
margin: 0; | |
font: 400 15px/1.8 "Lato", sans-serif; | |
color: #fff; | |
} | |
.bg_img-1, .bg_img-2, .bg_img-3 { | |
position: relative; | |
opacity: 0.65; | |
background-attachment: fixed; | |
background-position: center; | |
background-repeat: no-repeat; | |
background-size: cover; | |
} | |
.bg_img-1 { | |
background-image: url("https://4.bp.blogspot.com/-XwOZSclEXxY/V06vN7CA0CI/AAAAAAAAAcs/F6R-a9PbXp4rmlGoH7IsyZPANaB8lWoygCK4B/s1600/website-design-iin-coimbatore.jpg"); | |
min-height: 100%; | |
} | |
.bg_img-2 { | |
background-image: url("https://3.bp.blogspot.com/-lJ0LTS_RqT0/V0aFU0TDkUI/AAAAAAAAAcQ/kt8d5dZnFnAOidp4JWvCwIE7hgU0uwCgACK4B/s1600/geek%2Btimeline2.png"); | |
min-height: 400px; | |
} | |
.title { | |
position: absolute; | |
left: 0; | |
top: 50%; | |
width: 100%; | |
text-align: center; | |
color: #000; | |
} | |
.title span.border { | |
background-color: #9C27B0; | |
color: #fff; | |
padding: 18px; | |
font-size: 25px; | |
letter-spacing: 10px; | |
} | |
h3 { | |
letter-spacing: 5px; | |
text-transform: uppercase; | |
font: 20px "Lato", sans-serif; | |
color: #fff; | |
} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="bg_img-1"> | |
<div class="title"> | |
<span class="border">SCROLL DOWN</span> | |
</div> | |
</div> | |
<div style="color: #777;background-color:#9C27B0;text-align:center;padding:50px 80px;text-align: justify;"> | |
<h3 style="text-align:center;">Title</h3> | |
<p style="color:#fff">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> | |
</div> | |
<div class="bg_img-2"> | |
<div class="title"> | |
<span class="border" style="background-color:transparent;font-size:25px;color: #f7f7f7;">Title</span> | |
</div> | |
</div> | |
<div style="position:relative;"> | |
<div style="color:#ddd;background-color:#000;text-align:center;padding:50px 80px;text-align: justify;"> | |
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been</p> | |
</div> | |
</div> |
No comments :
Post a Comment