Pen Settings



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


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


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.


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.


                <div class="column">

<div class="lodge_slider" id="slider-1">
  <nav class="lodge_slider__nav">
      <a href="#slider-1__slide-1">Slide 1</a>
      <a href="#slider-1__slide-2">Slide 2</a>
      <a href="#slider-1__slide-3">Slide 3</a>
  <div class="lodge_slider__slider">
    <div class="lodge_slider__slide" id="slider-1__slide-1">
      <img src="">
    <div class="lodge_slider__slide" id="slider-1__slide-2">
      <img src="">
    <div class="lodge_slider__slide" id="slider-1__slide-3">
      <img src="">


                .lodge_slider {
  /* hide slides outside of view */
  overflow: hidden;

.lodge_slider__slide {
  float: left;
  width: 100%;

.lodge_slider__slide img {
  max-width: 100%;
  display: block;

.lodge_slider__slider {
  /* for animation */
  position: relative;

* {
  box-sizing: border-box;
.column {
  width: 35%;
  margin: 0 auto;


                // Plugin framework from

// Best practice: ensure $ is safe
(function($) {
  // Extending jQuery here just because it depends on it so might as well.
  $.lodgeSlider = function(el, options) {
    // To avoid scope issues, use 'base' instead of 'this'
    // to reference this class from internal events and functions.
    var base = this;
    // Access to jQuery and DOM versions of element
    base.$el = $(el);
    base.el = el;
    // Natural width at start
    base.baseWidth = base.$el.width();
    // Add a reverse reference to the DOM object
    base.$"lodgeSlider", base);
    // Commonly referenced elements
    base.slider = base.$el.find(".lodge_slider__slider");
    base.allSlides = base.$el.find(".lodge_slider__slide");
    base.allNavLinks = base.$el.find(".lodge_slider__nav a");
    base.init = function() {
      base.options = $.extend({},$.lodgeSlider.defaultOptions, options);
      // Set slides to fixed size
      base.allSlides.css("width", base.baseWidth);
      // Count slides and make slider as wide as it needs to be. +1 to account for bad pixel rounding.
      var numSlides = base.findNumSlides();
      base.slider.css("width", numSlides*100+1 + "%");
    base.bindUI = function() {
      base.allNavLinks.on("click", function(event) {
        var id = this.hash;
        // Stop browser from going to #hash link
    base.findNumSlides = function() {
      return base.allNavLinks.length;
    base.changeSlide = function(id) {
      var pos = $(id).index();
      var slideTo = pos * base.baseWidth;
        "left": -slideTo + "px"
      }, base.options.speed);
    // Run initializer
  $.lodgeSlider.defaultOptions = {
    "speed": 2000
  $.fn.lodgeSlider = function(options){
    return this.each(function(){
      (new $.lodgeSlider(this, options));

// Kick it off!
  "speed": 100

// Things could do
- Make CSS do the moving instead of JS
- Fix rounding error
- Auto create the navigation
- Make sure to test multiple sliders
- Allow linking to slides from hash
- Touch support (slide to slides)
- API for adding slides
- API for changing slides
- Media features like expanding images or auto-playing/stopping video
- Theme examples
- Reset on width change