I'm trying to achieve the following effect:
The first container, which has among others a class called .top-container, has a height of about one and a half pages. In the beginning, the user shall be able to scroll until the end of this container, but as soon as he reaches it, the container shall become fixed and the following elements are supposed to overlap it by scrolling.
My approach was to detect when the user reaches top-container's end, in order to then change its position to fixed. But how do I detect when the user has reached a certain scroll point?
Are there other approached to achieve the desired effect?
My code:
<div class="container-fluid px-0 top-container">
<div class="container-fluid bg-test justify-content-center min-vh-100 d-flex">
<h1 class="align-self-center">PURE</h1>
</div>
<div class="container-fluid justify-content-center d-flex collections" *ngIf="collections">
<div class="row align-self-center justify-content-around">
<div class="col-12 mb-5 text-center">
<h1>ALL COLLECTIONS</h1>
</div>
<div class="col-3" *ngFor="let collection of collections">
<div class="flex-row">
<div class="col-12 text-center">
<h4>{{collection.name}}</h4>
<p>- {{collection.desc}} -</p>
</div>
<div class="col-12 d-flex justify-content-center">
<img [src]="collection.image" [alt]="collection.name" class="w-75 align-self-center">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="padding-top">
<app-slider></app-slider>
<app-presentation></app-presentation>
</div>
CSS:
.top-container {
background-color: #EDEDED;
.collections {
padding: 5%;
background-color: white;
h1 {
font-family: "Zuric Light";
text-transform: uppercase;
color: #D3072A;
}
h4 {
font-family: "Zuric Light";
text-transform: uppercase;
}
p {
font-family: "Zuric Light";
}
}
.bg-test {
background-image: url("/assets/images/products/pure/pure-upper-side-red.png");
background-position: bottom left;
background-size: contain;
background-repeat: no-repeat;
h1 {
line-height: 1;
margin: 0;
font-family: "Zuric Bold";
color: white;
font-size: 200px;
text-transform: uppercase;
&::first-letter {
margin-left: -0.05em;
}
}
p {
color: white;
font-family: "Zuric Light";
font-size: 30px;
}
}
}