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

              
                <!-- demo shown on https://dev.to/fcalderan/a-css-carousel-with-snapping-points-and-a-scroll-linked-navigation-5h6j -->


<section class="slider">
   <div>
      <ul id="s">
         <li id="s1">
            <img src="//fabrizio.dev/demo/tesseract1.jpg" 
                 alt="Daniel Tompkins (Portals 2020)" />
         </li>
         <li id="s2">
            <img src="//fabrizio.dev/demo/tesseract2.jpg" 
                 alt="TesseracT (Portals 2020)" />
         </li>
         <li id="s3">
            <img src="//fabrizio.dev/demo/tesseract3.jpg" 
                 alt="Amos Prem Williams (Portals 2020)"/>
         </li>
         <li id="s4">
            <img src="//fabrizio.dev/demo/tesseract4.jpg" 
                 alt="TesseracT (Portals 2020)"/>
         </li>
         <li id="s5">
            <img src="//fabrizio.dev/demo/tesseract5.jpg" 
                 alt="TesseracT (Portals 2020)"/>
         </li>
      </ul>
   </div>
   
   
   <nav>
      <a href="#s1" title="title slide 1">
         Go to Slide 1</a>
      <a href="#s2" title="title slide 2">
         Go to Slide 2</a>
      <a href="#s3" title="title slide 3">
         Go to Slide 3</a>
      <a href="#s4" title="title slide 4">
         Go to Slide 4</a>
      <a href="#s5" title="title slide 5">
         Go to Slide 5</a>
   </nav>   
</section>
              
            
!

CSS

              
                .slider div {
   /* need to hide the horizontal scrollbar of 
    * the inner list
    */
   overflow: hidden;   
   
   /* using logical properties instead of
    * width and/or height
    */
   inline-size: 80%;
   min-inline-size: 300px;
   max-inline-size: 680px;   
   margin: 4rem auto;
   aspect-ratio: 2 / 1;
   border: 1px #e2e2e2 solid;
   box-shadow: 0 0 60px rgba(0, 0, 20, .6);
   border-radius: 1rem;
}


.slider ul {
   display: flex;
   flex-flow: row nowrap;
   overflow-x: scroll;
   scroll-snap-type: x mandatory;
   scroll-behavior: smooth;
   cursor: ew-resize;   
   
   /* clip away the scrollbar */
   block-size: calc(100% + 25px);
   
}

.slider li {
   flex: 0 0 100%;
   scroll-snap-align: start;
   scroll-snap-stop: always;
   /* restore the actual height of the slider */
   block-size: calc(100% - 25px);
}

.slider img {
   object-fit: cover;
   max-inline-size: 100%;
   block-size: 100%; 
}


.slider nav {
   position: relative;
   display: flex;
   margin: 0 auto;
   inline-size: max-content;
   
   /* DRY: set here the gap between the dots,
    * we will need it later to set the position
    * of the nav::before pseudoelement
    */
   --gap: .8rem;
   gap: var(--gap, .5rem);
}





.slider nav a {
   inline-size: 1rem;
   aspect-ratio: 1;
   border-radius: 50%;
   background: #9bc;
   text-indent: 100%;
   overflow: hidden;
   white-space: nowrap;
   opacity: .33;
}



              
            
!

JS

              
                /* no JS */
              
            
!
999px

Console