cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="full-screen flex-center--all">
  <div class="full-width p12">
    <div class="image-container" id="image-container"></div>
    
    <div class="flex-center--h">
      <div>
        <div class="track">
          <div class="track__img">
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/62921/horse-dragon-horse.png" alt="">
          </div>
          <div class="track__track-container">
            <input type="range" min="0" max="8" step="1" value="0" id="rango">
          </div>
          <div class="track__img">
            <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/62921/horse-dragon-dragon.png" alt="">
          </div>
        </div>
      </div>
    </div>
    <h1>Concept and artwork is all <a href="http://iguanamouth.tumblr.com/post/162370628217/forbidden-knowledge" target="_blank">@iguanamouth</a></h1>
  </div>
</div>
            
          
!
            
              h1 {
  font-size: 1.5em;
  font-family: 'Helvetica', sans-serif;
  font-weight: 400;
  color: #A4A9A7;
  text-align: center;
  a {
    color: inherit;
  }
}

.p12 {
  padding: 12px;
}
.full-screen {
  height: 100vh;
  width: 100vw;
}
.full-width {
  width: 100%;
}
.flex-center--all {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-center--h {
  display: flex;
  justify-content: center;
}

.track {
  display: flex;
  margin: 0 auto;
  width: 100%;
}
.track__img {
  min-width: 20px;
}
.track__track-container {
  margin-left: 20px;
  margin-right: 20px;
}

.image-container__img {
  display: none;
  margin: 0 auto;
  max-width: 100%;
}
.image-container__img--show {
  display: block;
}





























// Styling Cross-Browser Compatible Range Inputs with Sass
// Github: https://github.com/darlanrod/input-range-sass
// Author: Darlan Rod https://github.com/darlanrod
// Version 1.4.1
// MIT License

$track-color: #eceff1 !default;
$thumb-color: #607d8b !default;

$thumb-radius: 0px !default;
$thumb-height: 59px !default;
$thumb-width: 22px !default;
$thumb-shadow-size: 4px !default;
$thumb-shadow-blur: 4px !default;
$thumb-shadow-color: rgba(0, 0, 0, .2) !default;
$thumb-border-width: 2px !default;
$thumb-border-color: #eceff1 !default;

$thumb-bg: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/62921/horse-dragon-line.jpg');

$track-width: 200px !default;
$track-height: 6px !default;
$track-shadow-size: 0px !default;
$track-shadow-blur: 0px !default;
$track-shadow-color: rgba(0, 0, 0, 0) !default;
$track-border-width: 0px !default;
$track-border-color: #cfd8dc !default;
$track-color: red;

$track-radius: 5px !default;
$contrast: 5% !default;

@mixin shadow($shadow-size, $shadow-blur, $shadow-color) {
  box-shadow: $shadow-size $shadow-size $shadow-blur $shadow-color, 0 0 $shadow-size lighten($shadow-color, 5%);
}

@mixin track {
  cursor: pointer;
  height: $track-height;
  transition: all .2s ease;
  width: $track-width;
}

@mixin thumb {
  // @include shadow($thumb-shadow-size, $thumb-shadow-blur, $thumb-shadow-color);
  // background: $thumb-color;
  background-image: $thumb-bg;
  // border: $thumb-border-width solid $thumb-border-color;
  // border-radius: $thumb-radius;
  cursor: pointer;
  height: $thumb-height;
  width: $thumb-width;
  transform: translateY(3px);
}

[type='range'] {
  -webkit-appearance: none;
  margin: $thumb-height / 2 0;
  width: $track-width;

  &:focus {
    outline: 0;

    &::-webkit-slider-runnable-track {
      background: lighten($track-color, $contrast);
    }

    &::-ms-fill-lower {
      background: $track-color;
    }

    &::-ms-fill-upper {
      background: lighten($track-color, $contrast);
    }
  }

  &::-webkit-slider-runnable-track {
    @include track;
    @include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color);
    background: $track-color;
    border: $track-border-width solid $track-border-color;
    border-radius: $track-radius;
  }

  &::-webkit-slider-thumb {
    @include thumb;
    -webkit-appearance: none;
    margin-top: ((-$track-border-width * 2 + $track-height) / 2) - ($thumb-height / 2);
  }

  &::-moz-range-track {
    @include track;
    @include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color);
    background: $track-color;
    border: $track-border-width solid $track-border-color;
    border-radius: $track-radius;
  }

  &::-moz-range-thumb {
    @include thumb;
  }

  &::-ms-track {
    @include track;
    background: transparent;
    border-color: transparent;
    border-width: ($thumb-height / 2) 0;
    color: transparent;
  }

  &::-ms-fill-lower {
    @include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color);
    background: darken($track-color, $contrast);
    border: $track-border-width solid $track-border-color;
    border-radius: $track-radius * 2;
  }

  &::-ms-fill-upper {
    @include shadow($track-shadow-size, $track-shadow-blur, $track-shadow-color);
    background: $track-color;
    border: $track-border-width solid $track-border-color;
    border-radius: $track-radius * 2;
  }

  &::-ms-thumb {
    @include thumb;
    margin-top: 0;
  }
}

            
          
!
            
              // nodelist foreach poly
if (window.NodeList && !NodeList.prototype.forEach) {
    NodeList.prototype.forEach = function (callback, thisArg) {
        thisArg = thisArg || window;
        for (var i = 0; i < this.length; i++) {
            callback.call(thisArg, this[i], i, this);
        }
    };
}

const resourcePath = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/62921/';
const range = document.getElementById('rango');
const imgContainer = document.getElementById('image-container');

range.addEventListener('input', (e) => {
  highlightImage(range.value)
});

function getImages() {
  for(let i = 0; i <= 8; i++) {
    getImage(i);
  }
}

function getImage(index) {
  return fetch(`${resourcePath}horse-dragon-${index}.jpg`)
    .then(res => res.blob())
    .then(imgBlob => {
      console.log(index)
      const img = document.createElement('img');
      img.classList.add('image-container__img');
      img.classList.add(`image-container__img--${index}`);
      if (index === 0) {
        img.classList.add('image-container__img--show');
      }
      const dataUrl = URL.createObjectURL(imgBlob);
      img.src = dataUrl;
      imgContainer.appendChild(img);

    })
}

function highlightImage(index) {
  const target = imgContainer.getElementsByClassName(`image-container__img--${index}`)[0]
  const imageElements = document.querySelectorAll('.image-container__img');
  imageElements.forEach(el => {
    el.classList.remove('image-container__img--show');
  })
  target.classList.add('image-container__img--show');
}

getImages();

            
          
!
999px
Loading ..................

Console