.block
each val in ['one', 'two', 'tree', 'four', 'five', 'six']
.block__element= val
View Compiled
html, body {
position: fixed;
width: 100%;
height: 100%;
overflow: hidden;
margin: 0;
border: 0;
padding: 0;
@media only screen and (min-width: 900px) {
position: relative;
overflow: auto;
}
}
.block {
--block-position: fixed;
--block-height: 100%;
scroll-snap-type: y mandatory;
position: var(--block-position);
height: var(--block-height);
width: 100%;
overflow: auto;
scroll-behavior: smooth;
-webkit-overflow-scrolling: touch;
@media only screen and (min-width: 900px) {
--block-position: relative;
--block-height: auto;
display: grid;
grid-gap: .5rem;
grid-template-rows: 33vh 33vh 33vh;
grid-template-columns: repeat(1fr,3);
grid-template-areas:
"one one six"
"two four six"
"tree five six";
}
&__element {
--element-height: 100vh;
font-family: sans-serif;
padding: .5rem;
position: relative;
height: var(--element-height);
text-transform: capitalize;
color: #fff;
font-size: 20vh;
font-weight: bold;
scroll-snap-align: center;
@media only screen and (min-width: 900px) {
--element-height: auto;
}
&:nth-child(1) {
grid-area: one;
background-color: #2b2d42;
}
&:nth-child(2) {
grid-area: two;
background-color: #8d99ae;
}
&:nth-child(3) {
grid-area: tree;
background-color: #bdd5ea;
}
&:nth-child(4) {
grid-area: four;
background-color: #ee6c4d;
}
&:nth-child(5) {
grid-area: five;
background-color: #ef233c;
}
&:nth-child(6) {
grid-area: six;
background-color: #d90429;
}
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.