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="slide-wrap">
        <div class="slideshow">

          <div class="slide-entry">
            <div class="slide-content">
              <h2>Slide One</h2>
              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id repudiandae magnam amet architecto, aliquam unde, fugit in optio, vitae natus debitis minima tempore adipisci placeat<br><br> esse quasi ullam incidunt a et sit suscipit, impedit nobis. Quos qui doloribus necessitatibus perspiciatis, aliquid obcaecati rerum ad sequi animi facilis at iusto optio!</p>
            </div>
          </div>

          <div class="slide-entry">
            <div class="slide-content">
              <h2>Video Slide</h2>
  <div class="embed-container">
    <iframe width="560" height="315" src="https://www.youtube.com/embed/SgLJj3a-41Q" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
              </div>
            </div>
          </div>

          <div class="slide-entry">
            <div class="slide-content">
              <h2>Mixed Content</h2>
               <img style="float:right" src="https://via.placeholder.com/350x150" alt="">
              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Id repudiandae magnam amet architecto, aliquam unde, fugit in optio, vitae natus debitis minima tempore adipisci placeat esse quasi ullam incidunt a et sit suscipit, impedit nobis.</p>
                
            </div>
          </div>

        </div>
        <ul class="slide-nav">
          <li id="prev-slide"><i class="fas fa-chevron-left"></i></li>
          <li id="next-slide"><i class="fas fa-chevron-right"></i></li>
        </ul>
      </div>
              
            
!

CSS

              
                body {
  font-family:'Open Sans', sans-serif;
}

h2 {
  font-weight:700;
  font-size:22px;
  margin-bottom:15px;
}

p {
  font-size:1.1em;
  line-height:1.3em;
}

.slide-wrap {
  position: relative;
    max-width:1000px;
  margin: 0 auto;
  transition:300ms;
}

.slideshow {
  position: relative;
  z-index: 10;
}

.slide-entry {
  position: absolute;
  top: 0;
  left: 0;
right: 0;
  margin:0 auto;
  text-align: center;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  padding: 20px 5%;
  transition:300ms;
&.active {
    opacity: 1;
    visibility: visible;
  }
}


.slide-nav {
  display: flex;
  justify-content: space-between;
  align-items:center;
  position: absolute;
  left: 0;
  bottom: 0;
  top: 50%;
  transform: translateY(-60%);
  width: 100%;
  list-style: none;
  padding: 0;
  z-index: 0;
  li {
    cursor: pointer;
    color:#ccc;
    font-size:25px;
  }
}

#prev-slide {
  margin-left:-20px;
}

#next-slide {
  margin-right:-20px;
}

/* Responsive Video Embeds
========================================================= */
.embed-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  max-width: 100%;
  height: auto;
}

.embed-container iframe,
.embed-container object,
.embed-container embed {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

              
            
!

JS

              
                var slideshow = document.querySelector('.slide-wrap');

if (slideshow != null ) { //make sure we don't run this script if the slideshow is not present

  var slides = document.querySelectorAll('.slide-entry'),
slideCount = slides.length,
currentSlide = 0,
slideHeight = null,
initialHeight = slides[0].clientHeight;

slides[0].classList.add('active'); //on load, activate the first slide

function moveToSlide(n) { // set up our slide navigation functionality
  slides[currentSlide].className = 'slide-entry';
  currentSlide = (n+slideCount)%slideCount;
  slides[currentSlide].className = 'slide-entry active';
  slideHeight = slides[currentSlide].clientHeight;
  slideshow.style.height = slideHeight + 'px';
  window.addEventListener('resize', function(){
    resizedSlideHeight = slides[currentSlide].clientHeight;
    slideshow.style.height = resizedSlideHeight + 'px';
  });
}

function nextSlide(e){
  moveToSlide(currentSlide+1);
  var code = e.keyCode;
  if( code == 39 ) {
    moveToSlide(currentSlide+1);
  }
};
function prevSlide(e){
  moveToSlide(currentSlide+-1);
  var code = e.keyCode;
  if( code == 37 ) {
    moveToSlide(currentSlide+-1);
  }
};

var slideHandlers = {
  nextSlide: function(element){
    document.querySelector(element).addEventListener('click',nextSlide);
    document.body.addEventListener('keydown',nextSlide, false);
  },
  prevSlide: function(element){
    document.querySelector(element).addEventListener('click',prevSlide);
    document.body.addEventListener('keydown',prevSlide, false);
  }
}

slideHandlers.nextSlide('#next-slide');
slideHandlers.prevSlide('#prev-slide');

// Dynamic slideshow height

  slideshow.style.height = initialHeight + 'px'; //on load, set the height of the slider to the first active slide

window.addEventListener('resize', function(){ // adjust the height of the slidehow as the browser is resized
  var resizedHeight = slides[0].clientHeight;
  slideshow.style.height = resizedHeight + 'px';
});

// Detect swipe events for touch devices, credit to Kirupa @ https://www.kirupa.com/html5/detecting_touch_swipe_gestures.htm
var initialX = null;
var initialY = null;
function startTouch(e) {
  initialX = e.touches[0].clientX;
  initialY = e.touches[0].clientY;
};
function moveTouch(e) {
  if (initialX === null) {
    return;
  }
  if (initialY === null) {
    return;
  }
  var currentX = e.touches[0].clientX;
  var currentY = e.touches[0].clientY;
  var diffX = initialX - currentX;
  var diffY = initialY - currentY;
  if (Math.abs(diffX) > Math.abs(diffY)) {
    if (diffX > 0) {
// swiped left
moveToSlide(currentSlide+1);
} else {
// swiped right
moveToSlide(currentSlide+-1);
}
}
initialX = null;
initialY = null;
e.preventDefault();
};

slideshow.addEventListener("touchstart", startTouch, false);
slideshow.addEventListener("touchmove", moveTouch, false);  

// optional autoplay function  
  setInterval(function(){
    nextSlide();
  },8000); 

} //end slideshow
              
            
!
999px

Console