"Scroll snap CSS"
Bootstrap 4.1.1 Snippet by iammohitverma

1
2
3
4
5
6
7
8
9
10
11
12
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<section>1</section>
<section>2</section>
<section>3</section>
<section>4</section>
<section>5</section>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
.container {
width: 100%;
height: 100vh;
overflow: auto;
overflow-y: scroll;
scroll-snap-points-y: repeat(100vh);
scroll-snap-type: y mandatory;
will-change: scroll-snap-type;
}
section {
/* position: sticky;
top: 0; */
display: flex;
align-items: center;
justify-content: center;
scroll-snap-align: start;
width: 100%;
height: 100vh;
color: #FFF;
background: black;
scroll-snap-align: start;
font-size: 20vw;
&:nth-child(2n + 2){
color: black;
background: yellow;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: