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

              
                <!-- All you need is this one div!-->
<div class="simple-ss" id="simple-ss"></div>


<!-- Some junk -->
<div class="content">
  <p>This is a proof-of-concept for a slideshow that doesn't use any Javascript. It does not have pages or left/right buttons etc.
  <ul>
    <li>Pick a static width and height for the slides.</li>
    <li>Place all your slides side-by-side in a <strong>single</strong> image.</li>
    <li>Set the image as the background of the div. Use the background-position property to set the initial position of 0px. Be sure to calculate where the position needs to be for each slide, they will be negative numbers.</li>
    <li>In the animation CSS, set the length of time for the entire slideshow to run. For my three images I used 13 seconds. If you have more images you will need to increase this as needed.</li>
    <li>For the keyframes, you need to do some math. It's (pics * 2) / 100. Use this as the multipler for each slide, with "100%" being the last keyframe. Each image needs to have multiple keyframes in order for the slideshow to "pause" on that image. I used two stops for each slide, hence "pics * 2". Notice how the last keyframe at 100% is also the position of the first image of the slideshow. So technically, the first image gets 3 keyframes. I hope this makes sense.
    <li>This project is using Codepen's built-in -prefix-free setting, otherwise you need all those prefixes too!</li>
    <li>The Javascript is optional and is only there to enable clicking on each banner. If you want, you can remove all that and use a click event just on the div itself (one link for the entire slideshow). You will have to calculate the range of positions you want to be enabled for each banner click event. For example on the first banner, it is only clickable until it scrolls about half way to the 2nd banner, then the click fires on the second banner.</li>
  </ul>
  </p>

<p>Images taken from random Lorempixel.com images.</p>
</div>
              
            
!

CSS

              
                /* USUAL STUFF */
body { margin:10px auto; text-align:center; }
.content { max-width:800px;text-align:left; margin:auto; }

/* THE DIV */
.simple-ss {
  width:800px;
  height:250px;
  background-color:red;
  margin:auto;
  background-image:url("https://imgur.com/download/OtK7XDW");
  background-position:0;
  background-repeat:no-repeat;
  background-size:cover;

/* ANIMATING STUFF */
  animation-name: slide;
  animation-duration: 13s;
  animation-direction: normal;
  animation-timing-function: ease;
  animation-iteration-count: infinite;
}

/* NOTE CODEPEN AUTOGENERATING -PREFIXES */
@keyframes slide {
  0% {background-position:0 0;}
  16.66% {background-position:0 0;}
  33.32% {background-position:-800px 0;}
  49.98% {background-position:-800px 0;}
  66.64% {background-position:-1600px 0;}
  83.30% {background-position:-1600px 0;}
  100% {background-position:0 0;}
}
              
            
!

JS

              
                el = document.getElementById("simple-ss");
el.onclick = links;

function links() {
  left = parseInt(getComputedStyle(el).getPropertyValue("background-position").split(" ", 1));
   
  /* DEFINE POSITIONS FOR CLICK EVENTS */
  if (left >= -400) {
  
    // First until about half way scrolled over
    alert("first");
    //window.open("https://www.google.com");
  
  } else if (left >= -1200) {
  
    // Second when half way scrolled either side
    alert("second");
    //window.open("https://www.google.com");
    
  } else if (left >= -1600) {
    
    // Third when over half way into banner
    alert("third");
    //window.open("https://www.google.com");
    
  }
   
}
              
            
!
999px

Console