I have combined two images in the heading; one on top of the other. My goal is to create a subtle vertical movement in the background image as the user scrolls, giving the illusion of depth. Both images share the same width, but the background image is taller.
To view the website, please click here:
After doing some research on Google, I came across implementations using CSS and JavaScript to achieve this effect, known as the Parallax effect.
Initially, the bottom of the background image should line up with the bottom of the front image when the page is at the top. As the user continues scrolling downwards and the header image disappears, I would like the top of the background image to align with the top of the front image to enhance the 3D illusion.
The design is responsive, and it would be great if the effect works seamlessly on both mobile phones and desktops. However, desktop compatibility is crucial. If CSS proves to be impractical or too complex, implementing javascript can also be an option.
body {
background: gray;
font-size: 140%
}
.content {
margin: 50px auto 0px auto;
max-width: 1100px;
padding-bottom: 2000px;
padding-top: 30px;
background-color: white;
border: solid black;
border-width: 0px 16px 0px 16px;
}
.margin-content {
margin: 30px 80px 0px 100px;
}
.header-img {
width: 100%;
background-image: url("https://i.stack.imgur.com/r6CD4.jpg");
background-size: contain;
}
<div class="content">
<div class="margin-content">
<h1> My Brand </h1>
</div>
<img src="https://i.stack.imgur.com/uxvh2.png" class="header-img" />
<div class="margin-content">
<h2>Lorem ipsum dolor sit amet..</h2>
<p>..consectetur adipiscing elit. Fusce ex erat, vehicula vitae sapien vel, dignissim ornare odio.</p>
</div>
</div>
</div>
<p style="color:white;text-align: center; position: relative; top:13px">© 2048 My Brand</p>
Any assistance provided will be greatly valued! :)