Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                .scroll-indicator

main
    h1 CSS-only scroll indicator
    
    p 
        strong Adapted from #[a(href="https://codepen.io/MadeByMike/pen/ZOrEmr" target="_blank") this pen]. I re-wrote the CSS to use an element instead of the body, and added variables to change the bar position (top or bottom), the bar height and the bar colours. For no colour gradient, use the same value for #[code $bar-color] and #[code $bar-color2].
        
    hr
        
    p I was interested to see if I could make a scroll indicator #[a(href="https://codepen.io/derekjp/pen/pJzpxB" target="_blank") like this] with just CSS.

    p You can! But maybe you shouldn't. This is an interesting consequence of a bunch of hacks held together with duct tape. It uses z-index hacks, gradient hacks and tricks with calc and viewport units.

    p Having said that, hacks are not always bad. I love hacks and many of us have made quite a good living selling floats and clearfixes.

    p The techniques used here are well supported, if not conventional. If you can read the CSS, understand how it works, and how to change it, and you think this works better for you than JavaScript, feel free to implement it. Just be aware of the z-index behaviour and possible conflict with other CSS using negative z-index.
    
    hr

    each section in [1, 2, 3, 4, 5, 6, 7]
    
        p Cras mattis consectetur purus sit amet fermentum. Donec id elit non mi porta gravida at eget metus. Donec id elit non mi porta gravida at eget metus. Aenean lacinia bibendum nulla sed consectetur.

        h3 Tristique Aenean Etiam Cras

        p Donec id elit non mi porta gravida at eget metus. Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue. Donec sed odio dui. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

        p Cras mattis consectetur purus sit amet fermentum. Donec id elit non mi porta gravida at eget metus. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Etiam porta sem malesuada magna mollis euismod. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec ullamcorper nulla non metus auctor fringilla.

        p Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec ullamcorper nulla non metus auctor fringilla. Sed posuere consectetur est at lobortis. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Aenean lacinia bibendum nulla sed consectetur. Nulla vitae elit libero, a pharetra augue.

        p Donec sed odio dui. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Cras mattis consectetur purus sit amet fermentum. Maecenas sed diam eget risus varius blandit sit amet non magna.

        ul
            li Ullamcorper Aenean Ornare
            li Ridiculus Lorem Malesuada Consectetur
            li Aenean Tristique Sit Lorem Purus</li>
            li Vehicula Egestas Mollis Cursus Nibh

        p Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Sed posuere consectetur est at lobortis. Sed posuere consectetur est at lobortis. Maecenas faucibus mollis interdum. Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean lacinia bibendum nulla sed consectetur. Nullam quis risus eget urna mollis ornare vel eu leo.
              
            
!

CSS

              
                // Variables

$bar-position: top
$bar-height: 5px
$bar-bg: transparent
$bar-color: #5400ff
$bar-color2: #e4514f
$page-bg: #fff


// Scroll indicator styles
// adapted from: https://codepen.io/MadeByMike/pen/ZOrEmr

body
    position: relative
    margin: 0

@supports (height: 100vh)
    .scroll-indicator
        width: 100%
        height: 100%
        position: absolute
        top: 0
        left: 0
        background: linear-gradient(to right top, $bar-color2, $bar-color 50%, $bar-bg 50%) no-repeat
        z-index: -1
    
        @if $bar-position == top
            background-size: 100% calc(100% - 100vh + #{$bar-height})
    
        @else
            background-size: 100% calc(100% + #{$bar-height})

        &:before
            content: ''
            position: fixed
            width: 100%
            height: 100%
            background: $page-bg
    
            @if $bar-position == top
                top: $bar-height
        
            @else
                bottom: $bar-height

    
// Demo styles

main
    padding: 75px 15%
    font: 18px/#{1.65}  "Work Sans", arial, sans-serif

    a
        color: inherit
        border-bottom: 2px solid $bar-color
        text-decoration: none
        
    code
        display: inline-block
        font-size: 0.9em
        background: #f6f6f6
        padding: 1px 5px
        
    hr
        margin: 3em 0
              
            
!

JS

              
                
              
            
!
999px

Console