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

              
                <div class="slider js_slider">
  <div class="frame js_frame">
    <ul class="slides js_slides">
      <li class="js_slide">1</li>
      <li class="js_slide">2</li>
      <li class="js_slide">3</li>
      <li class="js_slide">4</li>
      <li class="js_slide">5</li>
      <li class="js_slide">6</li>
    </ul>
  </div>
  <span class="js_prev">&lt;</span>
  <span class="js_next">&gt;</span>
  <ul class="slider_navigation_dots"></ul>
</div>
              
            
!

CSS

              
                
/* PREREQUISITED CSS STYLES FOR LORY.JS */
.slider {}

.frame {
  // width: 880px; // was optional anyway cause we would want to set this dependign on the situation... like it could change in a media query and such
  position: relative;
  font-size: 0;
  line-height: 0;
  overflow: hidden;
  white-space: nowrap;
}

.slides {
  display: inline-block;
}

li {
  position: relative;
  display: inline-block;
  // width: 880px; // again... optional and we are settign them in the custom styles below instead
}




/* CUSTOM CSS STYLES FOR THE PEN AND THE SLIDER */
.slider {
  position: relative; // so we can position our navigation elements
  width: 980px; // set width to what we want on our custom styles and not in the prerequisite styles
  margin: 0 auto 20px; // quickly center the slider in the pen
}

.frame {
  background-color: #2E435A; // so we can see background color
  width: 880px; // set width smaller than slider
  height: 125px; // set the height to something...
  margin: 0 auto; // center inside slider
}

.slides {
  text-align: center; // center the text content of the example
  
  .js_slide {
    color: #fff; // color white so we can see it on the BG color
    width: 880px; // set to the same width as our frame
    height: 125px; // set to the same height as our frame
    font-size: 16px; // cause lory needs to set font size 0 on the frame 
    line-height: 125px; // centers vertically because it's the same as the height 
  }
}



// ARROW NAVIGATION
.js_prev, .js_next {
  position: absolute; // set absolute to fall to the nearest relative parent
  top: 50%; // set top 50% for arrows, then offset for their height
  margin-top: -10px; // offset for the height of the arrows
  display: block; // block...
  cursor: pointer; // cursor pointer for UX feedback
}

.js_prev {left: 0;} // using default class names lory expects
.js_next {right: 0;} // using default class names lory expects




// DOT NAVIGATION
.slider_navigation_dots {
  margin: 0; // remove default browser style
  padding: 0; // remove default browser style
  text-align: center; // center the dots
  margin-top: 10px; // add some space on top
  position: absolute; // absolute relative to parent
  width: 100%; // full width of the slider
  
  li {
    background-color: #eee; // grey the BG
    border: 1px solid #666; // border with box shadow... oooooh aaaaaah
    border-radius: 5px; // round them cause... dots
    box-shadow: inset 1px 1px 1px #888; // make them pretty
    display: inline-block; // inline cause row
    height: 10px; // set the height of the dots
    width: 10px; // set the width of the dots
    margin: 0 5px; // space the dots
    cursor: pointer; // cursor pointer for UX feedback
  }
  li.active {
    background-color: #41ABE5; // MAKE IT BLUE CAUSE ACTIVE!
    box-shadow: inset 2px 0px 2px -2px #333; // Change the boxshadow inset... just cause
  }
  
}


              
            
!

JS

              
                document.addEventListener('DOMContentLoaded', function () {
  var slider = document.querySelector('.js_slider');
  var slideCount = slider.querySelectorAll('.js_slide').length;
  var dotContainer = slider.querySelector('.slider_navigation_dots');
  var templateListItem = document.createElement('li');
  
  function handleEvents(e) {
    if (e.type === 'before.lory.init') {
      for (var i = 0, len = slideCount; i < len; i++) {
        var clone = templateListItem.cloneNode();
        dotContainer.appendChild(clone);
      }
      dotContainer.childNodes[0].classList.add('active');
    }
    if (e.type === 'after.lory.init') {
      for (var i = 0, len = slideCount; i < len; i++) {
        dotContainer.childNodes[i].addEventListener('click', function(e) {
          lorySlider.slideTo(Array.prototype.indexOf.call(dotContainer.childNodes, e.target));
        });
      }
    }
    if (e.type === 'after.lory.slide') {
      for (var i = 0, len = dotContainer.childNodes.length; i < len; i++) {
        dotContainer.childNodes[i].classList.remove('active');
      }
      dotContainer.childNodes[e.detail.currentSlide - 1].classList.add('active');
    }
  }

  slider.addEventListener('before.lory.init', handleEvents);
  slider.addEventListener('after.lory.init', handleEvents); 
  slider.addEventListener('after.lory.slide', handleEvents); 

  var lorySlider = lory(slider, {
    infinite: 1
  });
});
              
            
!
999px

Console