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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <div id='slider'>
  <div id='images'>
    <img src='https://www.friskies.com/Content/images/catconcoctions/home-cat.png' id='1'/><!--cats!-->
    <img src='https://pixabay.com/static/uploads/photo/2014/05/23/12/06/cat-351926_960_720.jpg' id='2'/><!--cats!-->
    <img src='https://pixabay.com/static/uploads/photo/2014/08/28/19/58/cat-430051_960_720.jpg' id='3'/><!--i love cats!-->
  </div>
  <div id='controls'>
    <div>
      <button id='previous'>&lt;</button>
    <button id='next'>&gt;</button>
    </div>
    <button id='toggle-fullscreen'>
      <i class='material-icons'>fullscreen</i>
    </button>
  </div>
</div>
<!--
  I like the minimal markup here. Makes it easier to insert images when needed. 
-->
              
            
!

CSS

              
                @mixin flexbox() {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

$gray: #f0f0f0;
$dark: #292929;

#slider {
    /*
      Container width and heights are arbitrary - I just chose what looks best. 
      For reference, on my site, container is at about 45% width on desktop, 100% on mobile
  */
    width: 50%;
    height: 350px;
    margin: 0 auto;
    @include flexbox();
    flex-flow: column nowrap;
    &.full {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      #images {
        img {
          height: 100%;
          width: auto;
          vertical-align: center;
          @media (max-width: 840px) {
            width: 100%;
            height: auto;
          }
        }
      }
    }
    #images {
      height: 90%;
      text-align: center;
      background: $dark;
      @include flexbox();
      justify-content: center;
      align-items: center;
      align-content: center;
      img {
        height: 100%;
        @media (max-width: 840px) {
          height: auto;
          width: auto;
          max-height: 100%;
          max-width: 100%;
        }
      }
    }
    #controls {
      height: 10%;
      background: $gray;
      @include flexbox();
      flex-flow: row nowrap;
      justify-content: space-between;
      div {
        height: 100%;
        @include flexbox();
        flex-flow: row nowrap;
        justify-content: flex-start;
        button {
          height: 100%;
        }
        #last {

        }
        #next {
          border-right: 2px solid lighten($gray, 15%);
        }
      }
      button {
        padding: 10px;
        background: transparent;
        border: none;
        outline: none;
        color: $dark;
        border-left: 2px solid lighten($gray, 15%);
        width: 50px;
        &:first-of-type {
          border-left: none;
        }
        &:active, &:hover, &:focus {
          outline: none;
        }
        &:hover {
          color: lighten($dark, 15%);
          background: darken($gray, 15%);
        }
      }
      #toggle-fullscreen {
        border-left: 2px solid lighten($gray, 15%);
        .material-icons {
          vertical-align: bottom;
        }
      }
    }
  }
              
            
!

JS

              
                $(document).ready(function() {
  
  //I.D. all the elements to be used
  var $last = $("#previous"); //previous button
  var $next = $("#next"); //next button
  var $full = $("#toggle-fullscreen"); //full screen toggle button
  var $car = $("#slider"); //the whole slider
  var $count = 1; //the current image
  var $total = 3; //the amount of images
  
  // hey, look, I know this isn't the best way to count the images
  //but for some reason, $("#images img").length isn't returning a value
  //trouble shooting that later on.

  $("#images img").hide(); //hide all images
  $("#" + $count).show(); //except the index image

  $last.click(function() {
    //when the 'last' button is clicked
    $("#" + $count).fadeOut(300, function() {
      //fade out the currently shown image
      
      //if the count is > 1
      if ($count > 1) {
        //decrement count
        $count--;
      } else {
        //else, loop back around so that the last image is shown
        $count = $total;
      }

      //find the next image
      $item = $("#" + $count);
      
      //fade in the next image
      $item.fadeIn(300);
    });
  })

  $next.click(function() {
    //when the 'next' button is clicked
    $("#" + $count).fadeOut(300, function() {
      //fade out the currently shown image
      
      //if the count is less than the total amount of image
      if ($count < $total) {
        //increment the count
        $count++;
      } else {
        //else, loop back around so that the first image is shown
        $count = 1;
      }

      //find the next image
      $item = $("#" + $count);
      
      //fade in the next image
      $item.fadeIn(300);
    });
  })

  $full.click(function() {
    //when the fullscreen toggle is clicked
    
    //if the slider is already full screen
    if ($car.hasClass('full')) {
      //remove the fullscreen class
      $car.removeClass('full');
      
      //change the button icon to the 'fullscreen' icon
      $full.html('<i class="material-icons">fullscreen</i>');
    } else {
      //else, add the fullscreen class
      $car.addClass('full');
      
      //change the button icon to the 'fullscreen exit' icon
      $full.html('<i class="material-icons">fullscreen_exit</i>');
    }
  })
})
              
            
!
999px

Console