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 class="container">

<header class="banner">

    <div class="cd-slider-wrapper">
      <ul class="cd-slider">
        <li class="visible">
          <div class="cd-svg-wrapper">
            <svg viewBox="0 0 1600 400">
              <title>Aimated SVG</title>
              <defs>
              <clipPath id="clipPolygon1">
                <polygon points="1600,0 0,0 0,387 320,316 687,364 795,337 1068,400 1386,325 1600,385"/>
              </clipPath>
              </defs>

              <image width="1600" height="400" clip-path="url(#clipPolygon1)" xlink:href="//lh3.googleusercontent.com/-0sSwSFGL3qk/V3etpKymR6I/AAAAAAAADUM/6-A_6rzilbIPaBWg6jgKvrYMOt2GnyIzwCCo/s1600/header-img_1600x400.jpg"></image>
            </svg>
          </div> <!-- .cd-svg-wrapper -->
        </li>

        <li>
          <div class="cd-svg-wrapper">
            <svg viewBox="0 0 1600 400">
              <title>Aimated SVG</title>
              <defs>
              <clipPath id="clipPolygon2">
                <polygon points="1600,0 0,0 0,387 320,316 687,364 795,337 1068,400 1386,325 1600,385"/>
              </clipPath>
              </defs>

              <image width="1600" height="400" clip-path="url(#clipPolygon2)" xlink:href="//placehold.it/1600x400/b62043/ffffff"></image>
            </svg>
          </div> <!-- .cd-svg-wrapper -->
        </li>

        <li>
          <div class="cd-svg-wrapper">
            <svg viewBox="0 0 1600 400">
              <title>Aimated SVG</title>
              <defs>
              <clipPath id="clipPolygon3">
                <polygon points="1600,0 0,0 0,387 320,316 687,364 795,337 1068,400 1386,325 1600,385"/>
              </clipPath>
              </defs>

              <image width="1600" height="400" clip-path="url(#clipPolygon3)" xlink:href="//placehold.it/1600x400/288eb2/ffffff"></image>
            </svg>
          </div> <!-- .cd-svg-wrapper -->
        </li>

        <li>
          <div class="cd-svg-wrapper">
            <svg viewBox="0 0 1600 400">
              <title>Aimated SVG</title>
              <defs>
              <clipPath id="clipPolygon4">
                <polygon points="1600,0 0,0 0,387 320,316 687,364 795,337 1068,400 1386,325 1600,385"/>
              </clipPath>
              </defs>

              <image width="1600" height="400" clip-path="url(#clipPolygon4)" xlink:href="//placehold.it/1600x400/58ac39/ffffff"></image>
            </svg>
          </div> <!-- .cd-svg-wrapper -->
        </li>

      </ul> <!-- .cd-slider -->

      <ul class="cd-slider-navigation">
        <li><a href="#0" class="next-slide">Next</a></li>
        <li><a href="#0" class="prev-slide">Prev</a></li>
      </ul> <!-- .cd-slider-navigation -->

      <ol class="cd-slider-controls">
        <li class="selected"><a href="#0"><em>Item 1</em></a></li>
        <li><a href="#0"><em>Item 2</em></a></li>
        <li><a href="#0"><em>Item 3</em></a></li>
        <li><a href="#0"><em>Item 4</em></a></li>
      </ol> <!-- .cd-slider-controls -->
    </div> <!-- .cd-slider-wrapper -->

</header>

<main>

<article class="content">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia veniam, eveniet quos, explicabo ab iste quibusdam aliquid molestias deserunt. Assumenda cum consectetur, dolorum dolore facere natus, nulla officiis rem deserunt!</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia veniam, eveniet quos, explicabo ab iste quibusdam aliquid molestias deserunt. Assumenda cum consectetur, dolorum dolore facere natus, nulla officiis rem deserunt!</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia veniam, eveniet quos, explicabo ab iste quibusdam aliquid molestias deserunt. Assumenda cum consectetur, dolorum dolore facere natus, nulla officiis rem deserunt!</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia veniam, eveniet quos, explicabo ab iste quibusdam aliquid molestias deserunt. Assumenda cum consectetur, dolorum dolore facere natus, nulla officiis rem deserunt!</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia veniam, eveniet quos, explicabo ab iste quibusdam aliquid molestias deserunt. Assumenda cum consectetur, dolorum dolore facere natus, nulla officiis rem deserunt!</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia veniam, eveniet quos, explicabo ab iste quibusdam aliquid molestias deserunt. Assumenda cum consectetur, dolorum dolore facere natus, nulla officiis rem deserunt!</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officia veniam, eveniet quos, explicabo ab iste quibusdam aliquid molestias deserunt. Assumenda cum consectetur, dolorum dolore facere natus, nulla officiis rem deserunt!</p>
</article>

<aside class="sidebar">
  <ul>
    <li>list-item</li>
    <li>list-item</li>
    <li>list-item</li>
    <li>list-item</li>
    <li>list-item</li>
  </ul>

</aside>
</main>

<footer><small>by <a href="//atelierbramdehaan.nl/">Bram de Haan</a></small> &middot; <small><a href="//codepen.io/atelierbram/pen/WxOQjO/">on Codepen</a></small> &middot; <small>javascript for slider adapted from <a href="https://twitter.com/guerriero_se">Sebastiano Guerriero</a>’s <a href="https://codyhouse.co/gem/animated-svg-image-slider/">Animated SVG Image Slider on CodyHouse</a></small></footer>
</div> 
              
            
!

CSS

              
                @import "bourbon";
// center vertically and/or horizontally an absolute positioned element

@mixin center($xy:xy) {
  @if $xy == xy {
    left: 50%;
    top: 50%;
    bottom: auto;
    right: auto;
    @include transform(translateX(-50%) translateY(-50%));
  }
  @else if $xy == x {
    left: 50%;
    right: auto;
    @include transform(translateX(-50%));
  }
  @else if $xy == y {
    top: 50%;
    bottom: auto;
    @include transform(translateY(-50%));
  }
}

$red: #d80032;

*,
*::after,
*::before {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
  vertical-align: baseline;
}

html,
body {
 background-color: #000;
 min-height: 100%;
}

body {
 font: 100%/1.5 sans-serif;
 box-sizing: border-box;
}

.wf-active body {
  font-family: "Source Sans Pro", sans-serif;
}
.container {
  margin: 0 auto;
  max-width: 100em; // 1600px
  background-color: #1c1c1c;
  overflow: auto;

  @media (min-width:960px) {
    background-image: url("data:image/svg+xml;charset='utf8',%3Csvg xmlns='http://www.w3.org/2000/svg' width='960' height='10' viewBox='0 0 960 10'%3E%3Crect fill='rgb(255,255,255)' width='665' height='10'/%3E%3Crect fill='rgb(28,28,28)' width='275' height='10' x='665'/%3E%3Crect fill='rgb(255,255,255)' width='10' height='10' x='950'/%3E%3C/svg%3E");
    background-repeat: repeat-y;
    background-position: center top;
  }

  @media (min-width:1600px) {
    background-image: url("data:image/svg+xml;charset='utf8',%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 400'%3E%3Cpolygon fill='rgb(255,255,255)' points='687,364 320,316 320,400 985,400 985.003,380.847 795,337'/%3E%3C/svg%3E"),url("data:image/svg+xml;charset='utf8',%3Csvg xmlns='http://www.w3.org/2000/svg' width='1600' height='400' viewBox='0 0 1600 400'%3E%3Cpolygon fill='rgb(28,28,28)' points='1270,350 1068,380 985,380 985,400 1270,400'/%3E%3Cpolygon fill='rgb(255,255,255)' points='1270,342.35 1068,390 985,370.85 985,360.85 1068,380 1270,332.35'/%3E%3Cpolygon fill='rgb(216,0,50)' points='1270,352.35 1068,400 985,380.85 985,370.85 1068,390 1270,342.35'/%3E%3Cpolygon fill='rgb(255,255,255)' points='1280,329.984 1270,332.35 1270,400 1280,400'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center 5px, center 25px;
    background-size: contain;
  }
}

main {
  max-width: 60em; // 960px
  margin: 0 auto;
  border-right: 10px solid #fff;
  overflow: auto;
  padding-bottom: 2em;
}

.content {
  background-color: #fff;
  padding: 3em 2em;

  @media (min-width:960px) {
    float: left;
    width: 70%;  // 70 * 9.5 =  665px
  }
}

.sidebar {
  color: #fff;

  @media (min-width:960px) {
    float: right;
    width: 30%; //  30 * 9.5 = 285px
  }

}

ul[class*="cd-slider"] {
  list-style: none;
}

.sidebar ul {
  padding: 2em;
  margin-top: 2em;
  list-style: circle;
}

.sidebar ul li {
  font-size: 1em;
  margin-left: 1.5em;
}

.content p {
  padding: .5em 0;
  max-width: 40em;
}

img, svg, image {
  max-width: 100%;
}

footer {
  text-align: center;
  background-color: #000;
  color: silver;
  padding: .5em 1em;
  letter-spacing: 1px;
  word-spacing: -1px;
}

footer a {
  display: inline-block;
  color: #fff;
  padding: .5em 0 .25em;
  text-decoration: none;
  box-shadow: inset 0 -6px 0 transparent;
  transition: all .3s;
}

footer a:hover {
  box-shadow: inset 0 -6px 0 #4d4d4d;
}
/* --------------------------------

Slider

-------------------------------- */

.cd-slider-wrapper {
  position: relative;
  max-width: 1600px;

  /* hide horizontal scrollbar on IE11 */
  overflow-x: hidden;
}

.cd-slider > li {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  transition: opacity 1s;

  /* hide vertical scrollbar on IE11 */
  overflow: hidden;

  &.visible {
    position: relative;
    z-index: 2;
    opacity: 1;
  }

  &.is-animating {
    z-index: 3;
    opacity: 1;
  }
}

.cd-slider .cd-svg-wrapper {
  /* using padding Hack to fix bug on IE - svg height not properly calculated */
  height: 0;
  // padding-bottom: 57.15%;
  padding-bottom: 25%;
  position: relative;
  // top: -24px;
}

.cd-slider-wrapper svg {
  position: absolute;
  top:0;
  right:0;
  bottom:0;
  left:0;
  background-color: #fff;

  @media (min-width: 960px) {
    background-color: inherit;
  }
}


/* --------------------------------

Slider navigation

-------------------------------- */

.cd-slider-navigation li {
  position: absolute;
  z-index: 3;
  @include center(y);
  right: 10px;
  height: 48px;
  width: 48px;

  a {
    display: block;
    height: 100%;
    overflow: hidden;
    text-indent: 100%;
    white-space: nowrap;
    color: transparent;
    background: url(//atelierbram.bitbucket.io/cdn/img/svg/cd-icon-arrows.svg) no-repeat 0 0;
    // @include transition(transform .2s);
    transition: transform .2s;

    .no-touch &:hover {
      // @include transform(scale(1.1));
      transform: scale(1,1);
    }
  }

  &:last-of-type {
    left: 10px;
    right: auto;

    a {
      background-position: -48px 0;
    }
  }
}

/* --------------------------------

Slider dots/controls

-------------------------------- */

.cd-slider-controls {
  position: absolute;
  bottom: 25%;
  @include center(x);
  z-index: 3;
  @include clearfix;
  text-align: center;
  width: 90%;

  @media (min-width: 1600px) {
    bottom: 20px;
  }

  li {
    display: inline-block;
    margin-right: 10px;

    &:last-of-type {
      margin-right: 0;
    }

    &.selected a {
      background-color: #fff;
    }

    @media (min-width: 1600px) {
      &.selected a {
        background-color: $red;
      }
    }
  }

  a {
    display: block;
    /* image replacement */
    overflow: hidden;
    text-indent: 100%;
    white-space: nowrap;
    color: transparent;

    height: 10px;
    width: 10px;
    border-radius: 50%;

    .no-touch &:hover {
      background-color: #fff;
    }

    border: 2px solid #fff;

    @media (min-width: 1600px) {
      border: 2px solid $red;
    }

  }
}

              
            
!

JS

              
                jQuery(document).ready(function(){
  var duration = 250,
  animating = false;

  //initialize the slider
  $('.cd-slider-wrapper').each(function(){
    initSlider($(this));
  });

  function initSlider(sliderWrapper) {
    //cache jQuery objects
    var slider = sliderWrapper.find('.cd-slider'),
    sliderNav = sliderWrapper.find('.cd-slider-navigation'),
    sliderControls = sliderWrapper.find('.cd-slider-controls').find('li');

    //update visible slide when user clicks next/prev arrows
    sliderNav.on('click', '.next-slide', function(event){
      event.preventDefault();
      nextSlide(slider, sliderControls);
    });
    sliderNav.on('click', '.prev-slide', function(event){
      event.preventDefault();
      prevSlide(slider, sliderControls);
    });

    //detect swipe event on mobile - update visible slide
    slider.on('swipeleft', function(event){
      nextSlide(slider, sliderControls);
    });
    slider.on('swiperight', function(event){
      prevSlide(slider, sliderControls);
    });

    //update visible slide when user clicks .cd-slider-controls buttons
    sliderControls.on('click', function(event){
      event.preventDefault();
      var selectedItem = $(this);
      if(!selectedItem.hasClass('selected')) {
        // if it's not already selected
        var selectedSlidePosition = selectedItem.index(),
        selectedSlide = slider.children('li').eq(selectedSlidePosition),
        visibleSlide = retrieveVisibleSlide(slider),
        visibleSlidePosition = visibleSlide.index(),
        direction = '';
        direction = ( visibleSlidePosition < selectedSlidePosition) ? 'next': 'prev';
        updateSlide(visibleSlide, selectedSlide, direction, sliderControls);
      }
    });

    //keyboard slider navigation
    $(document).keyup(function(event){
      if(event.which=='37' && elementInViewport(slider.get(0)) ) {
        prevSlide(slider, sliderControls);
      } else if( event.which=='39' && elementInViewport(slider.get(0)) ) {
        nextSlide(slider, sliderControls);
      }
    });
  }

  function retrieveVisibleSlide(slider, sliderControls) {
    return slider.find('.visible');
  }
  function nextSlide(slider, sliderControls) {
    var visibleSlide = retrieveVisibleSlide(slider),
    nextSlide = ( visibleSlide.next('li').length > 0 ) ? visibleSlide.next('li') : slider.find('li').eq(0);
    updateSlide(visibleSlide, nextSlide, 'next', sliderControls);
  }
  function prevSlide(slider, sliderControls) {
    var visibleSlide = retrieveVisibleSlide(slider),
    prevSlide = ( visibleSlide.prev('li').length > 0 ) ? visibleSlide.prev('li') : slider.find('li').last();
    updateSlide(visibleSlide, prevSlide, 'prev', sliderControls);
  }
  function updateSlide(oldSlide, newSlide, direction, controls, paths) {
    if(!animating) {
      //don't animate if already animating
      animating = true;
      updateNavSlide(newSlide, controls);
      newSlide.addClass('is-animating');
          oldSlide.removeClass('visible');
          newSlide.addClass('visible').removeClass('is-animating');
          animating = false;
    }
  }

  function updateNavSlide(actualSlide, controls) {
    var position = actualSlide.index();
    controls.removeClass('selected').eq(position).addClass('selected');
  }

 /* How to tell if a DOM element is visible in the current viewport?
  * http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
  */
  function elementInViewport(el) {
    var top = el.offsetTop;
    var left = el.offsetLeft;
    var width = el.offsetWidth;
    var height = el.offsetHeight;

    while(el.offsetParent) {
      el = el.offsetParent;
      top += el.offsetTop;
      left += el.offsetLeft;
    }

    return (
        top < (window.pageYOffset + window.innerHeight) &&
        left < (window.pageXOffset + window.innerWidth) &&
        (top + height) > window.pageYOffset &&
        (left + width) > window.pageXOffset
        );
  }
});
// end slider

// Google webfont
WebFontConfig = {
    google: { families: [ 'Source+Sans+Pro::latin' ] }
  };
  (function() {
    var wf = document.createElement('script');
    wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
    wf.type = 'text/javascript';
    wf.async = 'true';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(wf, s);
  })();
              
            
!
999px

Console