Skip to content

Instantly share code, notes, and snippets.

@Kvnbbg
Created September 6, 2024 14:06
Show Gist options
  • Save Kvnbbg/e1f27dcfbd2b9738abf18d6af4531886 to your computer and use it in GitHub Desktop.
Save Kvnbbg/e1f27dcfbd2b9738abf18d6af4531886 to your computer and use it in GitHub Desktop.

Revisions

  1. Kvnbbg created this gist Sep 6, 2024.
    7 changes: 7 additions & 0 deletions css-scroll-snap.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    CSS Scroll Snap
    ---------------


    A [Pen](https://codepen.io/denic/pen/ExNZmwd) by [Marko](https://codepen.io/denic) on [CodePen](https://codepen.io).

    [License](https://codepen.io/license/pen/ExNZmwd).
    21 changes: 21 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    <div class="wrapper">
    <div class="section">
    Content 1
    </div>

    <div class="section bg-blue">
    Content 2
    </div>

    <div class="section bg-green">
    Content 3
    </div>

    <div class="section">
    Content 4
    </div>

    <div class="section bg-blue">
    Content 5
    </div>
    </div>
    1 change: 1 addition & 0 deletions scripts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    <script src="https://codepen.io/denic/pen/YzyPzKG.js"></script>
    29 changes: 29 additions & 0 deletions style.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    body {
    margin: 0;
    padding: 0;
    }

    .wrapper {
    height: 100vh;
    overflow: auto;
    scroll-snap-type: y mandatory;
    }

    .section {
    scroll-snap-align: center;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #de5448;
    color: #fff;
    font-size: 3em;
    }

    .bg-blue {
    background: #4267b2;
    }

    .bg-green {
    background: #4CAF50;
    }
    2 changes: 2 additions & 0 deletions styles
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    <link href="https://codepen.io/denic/pen/YzyPzKG.css" rel="stylesheet" />
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />