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

              
                <div class="container">

  <div class="slider">

    <div class="slides">

      <!--  The last slide goes before the first one,
        because the slideshow shows the second slide on load by default. -->
      <div class="slides__img" id="" style="background-image: url('https://source.unsplash.com/1400x900/?mountain')">
        <div class="slides__img__filter"></div>
        <div class="slide__caption">
          <h1 class="slide__caption__title">Fifth slide</h1>
          <h2 class="slide__caption__subtitle">This is the fifth slide.</h2>
          <h3 class="slide__caption__text">Lorem ipsum dolor sit amet.</h3>
        </div>
      </div>

      <div class="slides__img" id="" style="background-image: url('https://source.unsplash.com/1400x900/?forest')">
        <div class="slides__img__filter"></div>
        <div class="slide__caption">
          <h1 class="slide__caption__title">First slide</h1>
          <h2 class="slide__caption__subtitle">This is the first slide.</h2>
          <h3 class="slide__caption__text">Lorem ipsum dolor sit amet.</h3>
        </div>
      </div>

      <div class="slides__img" id="" style="background-image: url('https://source.unsplash.com/1400x900/?sea')">
        <div class="slides__img__filter"></div>
        <div class="slide__caption">
          <h1 class="slide__caption__title">Second slide</h1>
          <h2 class="slide__caption__subtitle">This is the second slide.</h2>
          <h3 class="slide__caption__text">Lorem ipsum dolor sit amet.</h3>
        </div>
      </div>

      <div class="slides__img" id="" style="background-image: url('https://source.unsplash.com/1400x900/?sky')">
        <div class="slides__img__filter"></div>
        <div class="slide__caption">
          <h1 class="slide__caption__title">Third slide</h1>
          <h2 class="slide__caption__subtitle">This is the third slide.</h2>
          <h3 class="slide__caption__text">Lorem ipsum dolor sit amet.</h3>
        </div>
      </div>

      <div class="slides__img" id="" style="background-image: url('https://source.unsplash.com/1400x900/?rocks')">
        <div class="slides__img__filter"></div>
        <div class="slide__caption">
          <h1 class="slide__caption__title">Fourth slide</h1>
          <h2 class="slide__caption__subtitle">This is the fourth slide.</h2>
          <h3 class="slide__caption__text">Lorem ipsum dolor sit amet.</h3>
        </div>
      </div>

    </div>

  </div>
  <!-- / slider -->

  <!-- #Controls -->
  <a class="control fas fa-chevron-left" id="prev"></a>
  <a class="control fas fa-chevron-right" id="next"></a>

  <!-- #Position dots -->
  <div class="dots">
    <span class="dots__single" id=""></span>
    <span class="dots__single" id=""></span>
    <span class="dots__single" id=""></span>
    <span class="dots__single" id=""></span>
    <span class="dots__single" id=""></span>
  </div>

</div>
<!-- / slideshow -->
              
            
!

CSS

              
                /**
 * @Author: Andrea Alba
 * @Date:   2018-03-13T10:08:11+01:00
 * @Email:  subjuliodesign [at] gmail.com
 * @Project: Responsive Slideshow with jQuery
 * @Filename: style.css
 * @Last modified by:   Andrea Alba
 * @Last modified time: 2018-03-23T13:06:33+01:00
 * @Copyright: subjuliodesign
 */



/* =======================
#General
======================= */
* {margin: 0; padding: 0;}
body {position: relative; height: 100vh; font-family: 'Cinzel', serif; font-size: 16px;}



/* =======================
#Slideshow
======================= */
.container {height: 100vh;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
}

/* #Slider */
.slider {width: 100%; height: 100%; overflow: hidden;}

.slides {width: calc(100% * 5); height: 100%; position: relative; left: -100%;}
.slides__img {width: calc(100% / 5); height: 100%; float: left; background-position: center; background-repeat: no-repeat; background-size: cover; position: relative;}
.slides__img__filter {width: 100%; height: 100%; background-color: #000; position: absolute; top: 0; left: 0; z-index: 10; opacity: 0.3;}

/* #Captions */
.slide__caption {width: 100%; text-align: center; color: #fff; position: absolute; bottom: 5%; z-index: 20; opacity: 0}
.slide__caption__title {font-size: 3em; line-height: 1.05em;}
.slide__caption__subtitle {font-size: 2.25em; line-height: 1.25em;}
.slide__caption__text {font-size: 1.75em; line-height: 1.25em;}

/* #Controls */
.control {cursor: pointer; position: absolute; z-index: 20; top: calc(50% - 50px); padding: 15px; color: #fff; font-size: 3em; opacity: 0.5;}
.control:hover {background-color: #fff; opacity: 0.5; color: #000; color: rgba(0, 0, 0, 0.5);}
#prev {left: 0; border-radius: 0 5px 5px 0;}
#next {right: 0; border-radius: 5px 0 0 5px;}

/* #Indicators */
.dots {width: 100%; position: absolute; z-index: 20; bottom: 2%; text-align: center;}
.dots__single {cursor: pointer; display: inline-block; width: 20px; height: 6px; background-color: #fff; opacity: 0.5; margin: 0 5px;}
.dots__single:hover,
.dots__current {opacity: 1;}



/* ########################
Media Queries
######################## */

/* ------------------------
#Desktop, iPad Pro
------------------------ */
@media only screen and (min-width: 1024px) and (max-width: 1170px) {

}

/* ------------------------
#Display 12", iPad Pro portrait, iPad landscape
------------------------ */
@media only screen and (max-width: 1024px) {

}

/* ------------------------
#Medium Devices, Desktops
------------------------ */
@media only screen and (max-width: 992px) {

  /* #Captions */
  .slide__caption__title {font-size: 2.5em; line-height: 1.125em;}
  .slide__caption__subtitle {font-size: 2em;}

  /* #Controls */
  .prev,
  .next {font-size: 2.5em;}

}

/* ------------------------
#Display 5.5", iPad portrait, iPhone 6, 6s, 7, 8 portrait and landscape, iPhone 5s landscape
------------------------ */
@media only screen and (max-width: 768px) {

  /* #Captions */
  .slide__caption__subtitle {font-size: 1.625em;}
  .slide__caption__text {font-size: 1.5em;}

}

/* ------------------------
#Extra Small Devices, Phones
------------------------ */
@media only screen and (max-width: 480px) {

  /* #Captions */
  .slide__caption__title {font-size: 2em; line-height: 1.25em;}
  .slide__caption__subtitle {line-height: 1.15384615em;}
  .slide__caption__text {font-size: 1.375em; line-height: 1.13636364em;}

  /* #Controls */
  .prev,
  .next {font-size: 2em;}

}

/* ------------------------
#Display 4", iPhone 5s portrait
------------------------ */
@media only screen and (max-width: 320px) {

  /* #Controls */
  .prev,
  .next {font-size: 1.5em;}

}



/* =======================
#Hacks & Fixes
======================= */
/* Clearfix Hack*/
.clearfix:after {
  visibility: hidden;
  display: block;
  font-size: 0;
  content: " ";
  clear: both;
  height: 0;
}
/* IE6 */
* html .clearfix {
  zoom: 1;
}
/* IE7 */
*:first-child+html .clearfix {
  zoom: 1;
}

/* Box Size Hack */
*,
*:before,
*:after {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

              
            
!

JS

              
                /**
 * @Author: Andrea Alba
 * @Date:   2018-03-14T21:25:14+01:00
 * @Email:  subjuliodesign [at] gmail.com
 * @Project: Responsive Slideshow with jQuery
 * @Filename: slideshow_final.js
 * @Last modified by:   Andrea Alba
 * @Last modified time: 2018-03-23T13:07:33+01:00
 * @Copyright: subjuliodesign
 */



$(document).ready(function() {
  //==================================
  // #Slideshow with jQuery
  //==================================

  // id generator
  function idGenerator() {
    $(".slides__img").each(function(index, el) {
      $(this).attr("id", "slide_" + index);
    });
    $(".dots__single").each(function(index, el) {
      $(this).attr("id", "dot_" + index);
    });
  }

  // id extractor
  // at the end it focuses the current dot
  function dotsFocus() {
    $("[id^='dot_']").removeClass("dots__current");
    var id = $(".slides__img:eq(1)").attr("id");
    var n = Number(id.substr(-1));
    if (n === 0) {
      n = $(".slides__img").length;
    }
    $("#dot_" + (n - 1)).addClass("dots__current");
  }

  // slide up caption
  function captionSlideUp(d, e) {
    var $cap1 = $(".slide__caption:eq(1)");
    $cap1.animate(
      {
        bottom: "20%",
        opacity: 1
      },
      {
        duration: d,
        easing: e,
        complete: dotsFocus()
      }
    );
  }

  // slide down caption
  function captionSlideDown(d, e) {
    $(".slide__caption").animate(
      {
        bottom: "5%",
        opacity: 0
      },
      {
        duration: d,
        easing: e
      }
    );
  }

  // slide movement
  function slideMove(t) {
    if (t === "prev") {
      return $(".slides__img")
        .first()
        .before($(".slides__img").last());
    }
    if (t === "next") {
      return $(".slides__img")
        .last()
        .after($(".slides__img").first());
    }
  }

  // slide images
  function slideIt(l, d, e, t) {
    var $slides = $(".slides");
    captionSlideDown(150, "linear");
    $slides.animate(
      {
        left: l
      },
      {
        duration: d,
        easing: e,
        complete: function() {
          $slides.css("left", "-100%");
          slideMove(t);
          captionSlideUp(1700, "swing");
        }
      }
    );
  }

  // slide with dots
  function dotsControl(d, e) {
    $(".dots__single").click(function() {
      var currentId = parseInt(
        $(".dots__current")
          .attr("id")
          .substr(-1)
      );
      var clickId = parseInt(
        $(this)
          .attr("id")
          .substr(-1)
      );
      var max = $(".dots__single").length - 1;
      var half = Math.floor($(".dots__single").length / 2);
      var diff;
      if (currentId > clickId) {
        diff = currentId - clickId;
        if (diff === max) {
          diff = 1;
          l = "-200%";
          t = "next";
        } else if (diff <= half) {
          l = "0%";
          t = "prev";
        } else {
          diff--;
          l = "-200%";
          t = "next";
        }
      }
      if (currentId < clickId) {
        diff = clickId - currentId;
        if (diff === max) {
          diff = 1;
          l = "0%";
          t = "prev";
        } else if (diff <= half) {
          l = "-200%";
          t = "next";
        } else {
          diff--;
          l = "0%";
          t = "prev";
        }
      }
      for (var i = 0; i < diff; i++) {
        slideIt(l, d, e, t);
      }
    });
  }

  // slideshow
  function slideShow(d, e) {
    $("#prev").click(function() {
      var t = $(this).attr("id");
      slideIt("0%", d, e, t);
    });
    $("#next").click(function() {
      var t = $(this).attr("id");
      slideIt("-200%", d, e, t);
    });
    dotsControl(d, e);
  }

  idGenerator();
  captionSlideUp(1700, "swing");
  slideShow(800, "swing");
});

              
            
!
999px

Console