I am currently working on a straightforward application that requires implementing a parallax effect.
Here are the methods I have experimented with so far:
- Inserting an image within a div with the class parallax
.
- Subsequently, adding an overlay div with Bootstrap class card item-card card-block
, containing a headline, image, and text.
.parallax {
width: 100%;
height: 250px;
border-radius: 0;
}
.item-card {
flex-direction: column;
box-sizing: border-box;
display: flex;
place-content: center flex-start;
align-items: center;
margin: -24px 0 0;
width: 100%;
padding: 0;
border-radius: 18px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<div class="container mt-2">
<div class="parallax">
<img style="width: 100%" src="https://www.w3schools.com/howto/img_parallax.jpg" />
</div>
<div class="card item-card card-block">
<h1 class="card-title text-center">Some big text here as headline</h1>
<div class="card-body">
<img style="width: 100%" src="https://static.pexels.com/photos/7357/startup-photos.jpg" alt="Photo of sunset">
</div>
<h5 class="item-card-title mt-3 mb-3">Sierra Web Development • Owner</h5>
<p class="card-text">This is a company that builds websites, web apps and e-commerce solutions.</p>
</div>
</div>
I attempted using position:fixed
on the parallax
div, but it did not produce the desired outcome.
The aim is to have the image div positioned fixed while allowing the subsequent card div to scroll over it.
Converting the provided image into a background image resulted in the entire div being non-responsive.