Parallax Effect
Parallax Website Effect Using CSS
by Vikash Pareek
HTML
<header>
<div class="container">
<div class="logo">
<a href="#">logo</a>
</div>
<div class="navbar">
<ul>
<li>
<a href="#">html</a>
</li>
<li>
<a href="#">css</a>
</li>
<li>
<a href="#">wordpress</a>
</li>
<li>
<a href="https://webtutorialhindi.com/">learn</a>
</li>
</ul>
</div>
</div>
</header>
<div class="banner">
<h1>Creative HTML parallax Design</h1>
<a href="#">Scroll Down</a>
</div>
<div class="parallax">
<h2>Parallax 1</h2>
</div>
<div class="parallax parallax-1">
<h2>Parallax 2</h2>
</div>
CSS
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
html{
font-size: 65.5%;
}
body{
background: #000;
font-family: sans-serif;
}
a{
text-transform: uppercase;
text-decoration: none;
}
.container{
max-width: 70%;
margin: auto;
}
header {
padding-top: 2rem;
border-bottom: 1px solid #fff;
padding-bottom: 2rem;
}
header .container{
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
.logo{
margin-right: auto;
}
.logo a{
font-size: 2rem;
color: #fff;
font-weight: bold;
}
.navbar{
margin-left: auto;
}
li{
float: left;
list-style: none;
}
.navbar li a,.banner a{
font-size: 1.4rem;
padding-right: 4rem;
font-weight: bold;
color: #ffc107;
}
.navbar li:last-child a,.banner a{
padding: 1rem 2rem;
border: 1px solid #fff;
border-radius: 5px;
}
.banner{
margin-top: 30rem;
text-align: center;
}
h1{
font-size: 5rem;
text-transform: capitalize;
color: #fff;
}
h2{
color: #fff;
font-size: 5rem;
background: #000;
padding: 1rem 2rem;
text-align: center;
}
.banner a{
margin-top: 4rem;
display: inline-block;
}
.banner-bottom{
margin-top: 5rem;
width: 100%;
float: left;
}
.parallax{
background-image: url("https://picsum.photos/1920/500");
min-height: 500px;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
margin-top: 15rem;
display: flex;
justify-content: center;
align-items: center;
}
.parallax-1{
background-image: url("https://picsum.photos/1920/1000");
min-height: 1000px;
margin-top: 1rem;
}
@media screen and (max-width: 992px){
html{font-size: 40%;}
.parallax{min-height: 300px;}
.parallax-1{min-height: 500px;}
}
@media screen and (max-width: 520px){
.container{max-width:100%;padding: 0 15px;}
.banner h1{font-size: 25px;}
}