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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <header>
  <h1 class="title">Mini-slider</h1>
<p>The idea is quite simple, each dots is a link</p>
  <p>Each link points to <code>#1</code>, <code>#2</code> or <code>#3</code> (or more)</p> 
  <p>If the link points to <code>#2</code>, click on it, it will target <code>#3</code> </p>
  <p><code>data-slide="#"</code> on <code>.slider</code> indicates the active slide</p>  

</header> 
<!-- slider -->
         <div class="team-slider" id="team-slider">

            <div class="slider-container">
                <ul class="slider" data-slide="1"> 
                    <li class="slides" data-id="1" ><img src="http://magdeleine.co/wp-content/uploads/2014/09/2048-1400x929.jpg" alt="An image"></li>
                    <li class="slides" data-id="2" ><img src="http://magdeleine.co/wp-content/uploads/2014/09/4715168826_7a4cc9beed_o-1400x937.jpg" alt="An image"></li>
                    <li class="slides" data-id="3" ><img src="http://magdeleine.co/wp-content/uploads/2014/09/51H-1400x933.jpg" alt="An image"></li>
                </ul>
            </div>

            <div class="slider-controls">
                <a href="#3" class="control-left"><span></span></a>
                <a href="#2" class="control-right"><span></span></a>
            </div>
 
            <div class="slider-bullets">
                <ul>
                    <li class="bullet active"><a href="#1" id="bullet-1"></a></li>
                    <li class="bullet"><a href="#2" id="bullet-2"></a></li>
                    <li class="bullet"><a href="#3" id="bullet-3"></a></li>
                </ul>
            </div> 

        </div>
        <!-- // Slider -->
              
            
!

CSS

              
                @import "bourbon";


html,body{
  width: 100%;
  height: 100%;
  float: left;
  padding:0;
  margin: 0;
}


$size: 420; 
$sizeCtrl: 30;

$color-1: #007ee5; // Blue 
$color-2: #8899a7; // Active bullet & text

.team-slider{
  width: $size + $sizeCtrl + px;
  margin: 14em auto;
  .slider-container{
    width: $size+px;
    overflow: hidden;
    margin:  1em auto;

    ul.slider{
      width: $size*3+px;
      margin:0;
      padding:0;
      list-style: none;  
      transition: margin .3s ease;

      li.slides{
        margin:0;
        padding:0;

        float: left;
        width: $size+px;

        img{
          max-width: $size+px;
          display: block;
        }
      }
    }
  }

  // Controls
  .slider-controls{
    .control-left{
      float: left;
      margin-left: -45px;
    }
    .control-right{
      float: right;
      margin-right: -45px;
    }

    a {
      display:block;
      
      span{
        width: 16px;
        height: 16px;
        display: block;
        margin: -(($size/2) - 16px) 12px 0; 
        background: $color-1;
        border-radius: 100%;

      }
      &:active{
        span{
          transform: scale(.9);
          animation: drop .3s linear;
              box-shadow: 0 0 0 4px white,0 0 0 5px rgba(#007EE5, .3);

        }
      }
    }
  }

  // Bullets 
  .slider-bullets ul {
    list-style: none;
    width: 103px;
    height: 16px;
    display: block;
    margin: 20px auto 55px;
    padding: 0;
  }
  .slider-bullets ul li {
    width: 16px;
    height: 16px;
    display: block;
    float: left;
    margin: 0 12px;
    background: $color-1;
    border-radius: 100%;

    &:active{
      transform: scale(1.1);
      animation: drop .3s ease;
    box-shadow: 0 0 0 4px white,0 0 0 5px rgba(#007EE5, .3);
    }
  }
  .slider-bullets ul li:nth-child(1) {
    margin-left: 0;
  }
  .slider-bullets ul li:nth-child(3) {
    margin-right: 0;
  }
  .slider-bullets ul li.active {
    background: $color-2;
  }
  .slider-bullets ul li a {
    width: 100%;
    height: 100%;
    display: block;
  }
}


// Fancy stuff

@keyframes drop{
  0%{
    box-shadow:0 0 0 white;
  }
  80%{
    box-shadow: 0 0 0 4px white,0 0 0 5px rgba(#007EE5, .3);
  }
  100%{
    box-shadow: 0 0 0 4px white,0 0 0 5px rgba(#007EE5, .3);
  } 
}

// Header style

header{
  width: 100%;
  height: 100px;
  float: left; 
  padding: 2em 0;

  .title,p{
    text-align:center; 
    margin: 0; 
    padding: 0; 
    font-family: Helvetica, sans-serif; 
    font-weight: 300; 
    color: #007EE5;
    line-height: 24px;
  }
  .title{
    margin-bottom: .5em;
  }
  p{
    color: #8899A7; 
  }
}
              
            
!

JS

              
                $(function(){
  'use strict';

  // Slider functions
  function sliderPane(){

    function slide(){
      var sliderCtx = $('#team-slider');
      var slider = sliderCtx.find('.slider');
      var sliderWidth = slider.width();
      var slideWidth = sliderWidth/3;

      var arrLeft = $('.slider-controls .control-left');
      var arrRight = $('.slider-controls .control-right');

      var bullets = $('.slider-bullets .bullet a');


      // Some functions for the slider 
      function slideTo($url){

        function addCurrent($num){
          $('.slider').attr('data-slide', $num);
        }
        slider.css({
          marginLeft: 0
        });
        if($url === '#1'){
          slider.css({
            marginLeft: 0
          });

          addCurrent('1');
        }
        else if($url === '#2'){
          slider.css({
            marginLeft: '-'+slideWidth + 'px'
          });

          addCurrent('2');
        }
        else{
          slider.css({
            marginLeft: '-'+slideWidth*2 + 'px'
          });
          addCurrent('3'); 
        }

      }

      function colorBullets(){
        var slider = $('.slider');

        $('.team-slider a').on('click', function(){
          var num = slider.attr('data-slide');

          if(num === '1'){
            $('.slider-bullets .bullet').removeClass('active');
            $('.slider-bullets .bullet:nth-child(1)').addClass('active');

          }
          else if(num === '2'){
            $('.slider-bullets .bullet').removeClass('active');
            $('.slider-bullets .bullet:nth-child(2)').addClass('active');
          }
          else {
            $('.slider-bullets .bullet').removeClass('active');
            $('.slider-bullets .bullet:nth-child(3)').addClass('active');
          }

        }); 
      }
      // Make it slide ! 
      arrLeft.on('click', function(){ 

        var $this = $(this);

        var url = $this.attr('href');
        slideTo(url);

        if($this.attr('href') === '#3'){ 
          $this.attr('href', '#2'); 
          arrRight.attr('href', '#1'); 
        }  
        else if($this.attr('href') === '#2'){
          $this.attr('href', '#1'); 
          arrRight.attr('href', '#3');
        }
        else {
          $this.attr('href', '#3');
          arrRight.attr('href', '#2');
        }

      });
      arrRight.on('click', function(){
        var $this = $(this);
        var url = $this.attr('href'); 
        slideTo(url);

        if($this.attr('href') === '#3'){
          $this.attr('href', '#1');
          arrLeft.attr('href', '#2'); 
        }
        else if($this.attr('href') === '#1'){
          $this.attr('href', '#2'); 
          arrLeft.attr('href', '#3');
        }
        else {
          $this.attr('href', '#3');
          arrLeft.attr('href', '#1');
        }

      });
      bullets.on('click', function(){
        var url = $(this).attr('href');
        if (url == "#1"){
          arrLeft.attr('href', '#3');
          arrRight.attr('href', '#2');
        }
        else if (url == "#2"){
          arrLeft.attr('href', '#1');
          arrRight.attr('href', '#3');
        }
        else {
          arrLeft.attr('href', '#2');
          arrRight.attr('href', '#1');
        }
        
        slideTo(url);
      });
      colorBullets();
    }
    slide();
  }
  sliderPane();
})
              
            
!
999px

Console