Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <html>
  <head>
    <meta charset="utf-8">
    <title>Slideshow</title>
    <link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">
  </head>
  <body>
    <div class="container">
      <div class="arrow arrow-left"><i class="fas fa-chevron-circle-left"></i></div>
      <img src="https://images.unsplash.com/photo-1518640027989-a30d5d7e498e?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=f9575732a498c98486879d7000ab1d47" alt="">
      <img src="https://images.unsplash.com/photo-1505843378597-b96befae716e?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=9e69634f39ec7c08514fef902cfc85ac" alt="">
      <img src="https://images.unsplash.com/photo-1471138406156-7a89e687a062?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=7820fc816715b37942a793360b785c60" alt="">
      <div class="arrow arrow-right"><i class="fas fa-chevron-circle-right"></i>
      </div>
      <div class="dots">
        <div class="dot">
          <i class="far fa-dot-circle"></i>
        </div>
        <div class="dot">
          <i class="far fa-circle"></i>
        </div>
        <div class="dot">
          <i class="far fa-circle"></i>
        </div>
      </div>
    </div>
  </body>
</html>
              
            
!

CSS

              
                @mixin default($margin, $padding, $box-sizing) {
  margin: $margin;
  padding: $padding;
  box-sizing: $box-sizing;
}

@mixin dimension($width: auto, $height: auto) {
  width: $width;
  height: $height;
}

@mixin pos($position: absolute, $margin: auto, $top: auto, $bottom: auto, $left: auto, $right: auto) {
  position: $position;
  margin: $margin;
  top: $top;
  bottom: $bottom;
  left: $left;
  right: $right;
}

$color: cornsilk;

* {
  @include default(0, 0, border-box);
}

body, html {
  @include dimension(100%, 100%);
}

  .container {
    @include dimension(100%, 100%);
    position: relative;
    background: #355C7D;  /* fallback for old browsers */
    background: -webkit-linear-gradient(to right, #C06C84,   #6C5B7B, #355C7D);  /* Chrome 10-25, Safari 5.1-6 */
    background: linear-gradient(to right, #C06C84,           #6C5B7B, #355C7D); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
    overflow: hidden;
    img {
      @include dimension(100%, 100%);
      object-fit: cover;
      @include pos($top: 0, $bottom: 0, $left: 0, $right: 0);
      animation: fade 1s;
    }
    .arrow {
      z-index: 10;
      @include pos($top: 0, $bottom: 0);
      @include dimension(1.5rem, 1.5rem);
      font-size: 1.5rem;
      color: $color;
      opacity: 0.5;
      transition: opacity 1s;
      &:hover {
        cursor: pointer;
        opacity: 1;
      }
    }
    .arrow-left {
      left: 2%;
    }
    .arrow-right {
      right: 2%;
    }
    .dots {
      @include pos($left: 0, $right: 0, $bottom: 2%);
      @include dimension(7rem);
      z-index: 5;
      .dot {
        @include dimension(2rem, 2rem);
        display: inline-flex;
        align-content: center;
        justify-content: center;
        color: $color;
      }
    }
  }

@keyframes fade {
  from {opacity: 0.1}
  to {opacity: 1}
}
              
            
!

JS

              
                const imgs = document.querySelectorAll(".container img");
const dots = document.querySelectorAll(".dot i");
const leftArrow = document.querySelector(".arrow-left");
const rightArrow = document.querySelector(".arrow-right");

let currentIndex = 0;
let time = 5000; // default time for auto slideshow

const defClass = (startPos, index) => {
  for (let i = startPos; i < imgs.length; i++) {
    imgs[i].style.display = "none";
    dots[i].classList.remove("fa-dot-circle");
    dots[i].classList.add("fa-circle");
  }
  imgs[index].style.display = "block";
  dots[index].classList.add("fa-dot-circle");
};

defClass(1, 0);

leftArrow.addEventListener("click", function(){
  currentIndex <= 0 ? currentIndex = imgs.length-1 : currentIndex--;
  defClass(0, currentIndex);
});

rightArrow.addEventListener("click", function(){
  currentIndex >= imgs.length-1 ? currentIndex = 0 : currentIndex++;
  defClass(0, currentIndex);
});

const startAutoSlide = () => {
  setInterval(() => {
    currentIndex >= imgs.length-1 ? currentIndex = 0 : currentIndex++;
    defClass(0, currentIndex);
  }, time);
};

startAutoSlide(); // Start the slideshow
              
            
!
999px

Console