Skip to content

Instantly share code, notes, and snippets.

@kobitoDevelopment
Last active June 14, 2022 02:42
Show Gist options
  • Select an option

  • Save kobitoDevelopment/50ed33636fa4cadf5b816e0cbdb05aa5 to your computer and use it in GitHub Desktop.

Select an option

Save kobitoDevelopment/50ed33636fa4cadf5b816e0cbdb05aa5 to your computer and use it in GitHub Desktop.
<div class="container">
<div class="hoge box"></div>
<div class="fuga box"></div>
<div class="piyo box"></div>
</div>
.container {
scroll-snap-type: y mandatory;
/*
mandatory → 少しでもスクロールしたら次の要素にスナップ
proximity → 半分までのスクロールは前の要素にスナップ + 半分の位置では停止 + 半分を超えると次の要素にスナップ
*/
overflow: auto;
width: 100%;
height: 100vh;
.box {
width: 100%;
height: 100%;
scroll-snap-align: start;
&.hoge {
background-color: yellow;
}
&.fuga {
background-color: green;
}
&.piyo {
background-color: orange;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment