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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class='slider-container'>
  <div class='slide'><p>CSS Slider</p></div>
  <div class='slide'><p>No JavaScript</p></div>
  <div class='slide'><p>Manual Setup</p></div>
  <div class='slide'><p>Tedious to Update</p></div>

<div class='link'>
 <a href='https://codereview.stackexchange.com/questions/221167/css-image-slider-no-javascript' target='_blank'>Give feedback on CodeReview</a>
              /*  images:
  width: 100%;
  height: 500px;
  background: red; /* to test if background shows */
  overflow: hidden;
  position: relative; /* since slides are absolute */
  box-shadow: 0 2px 10px black;
  animation: 0.4s 0.2s both fadeIn;

  /* positioning all slides normal position to full size of slider and in view */
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;

  animation: 12s linear infinite sliderAnimation;
  animation-name: sliderAnimation;
  animation-duration: 12s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;

  border: 20px solid #1d1e22; /* thought it looked good */
  box-sizing: border-box; /* to keep total width at 100% */

  box-shadow: inset 0 0 20px black; /* inset shadow on the slides */

  display: flex;  /* to position the text inside*/

  /* City */
  background: no-repeat 50% 20%/cover url('https://i.imgur.com/zN8znQk.jpg');
  /* positioning for the text inside */
  justify-content: flex-end;
  align-items: flex-start;
  /* Nature Bridge */
  background: no-repeat center/cover url('https://i.imgur.com/qtwGd3b.jpg');

  /* 12s - 9s = 3s... Will start after 3s */
  animation-delay: -9s;

  /* Painting */
  background: no-repeat center/cover url('https://i.imgur.com/Qxdy5Ue.jpg');
  /* Will start after 6s */
  animation-delay: -6s;

  /* positioning for the text inside */
  justify-content: flex-end;
  align-items: center;
  /* Coffee */
  background: no-repeat bottom/cover url('https://images.pexels.com/photos/358591/pexels-photo-358591.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500');
  /* Will start after 9s */
  animation-delay: -3s;

  /* positioning for the text inside */
  justify-content: center;
  align-items: center;

@keyframes sliderAnimation{
  /* 4 slides, 20% in place and 5% transition time = 100% */
  0%{transform: translateX(0); opacity: 1;} /* starts in view */
  20%{transform: translateX(0); opacity: 1;} /* stays in view */
  25%{transform: translateX(-100%); opacity: 1;} /* slides out left */
  70%{transform: translateX(-100%); opacity: 0;} /* Doesn't matter at what percent: changes to transparent so can't see it travel back across to the right. */
  71%{transform: translateX(100%); opacity: 0;} /* Doesn't matter at what percent: moves off right */
  95%{transform: translateX(100%); opacity: 1;} /* Becomes transparent and Ready to slide on from the right */

.slide p{
  /*style for the text*/
  margin: 5vw;
  font-size: 3vw;
  color: white;
  text-shadow: 0.1vw 0.1vw black;
  font-family: Arial Black, Georgia, Garamond, Palatino, Trebuchet MS, Verdana;

.slide:last-of-type p{
  /* because white text on white background */
  text-shadow: 0 0 15px black;
  margin: 0;
  background: #3f4351;
  max-width: 100%;

  text-align: center;
  padding: 100px;

.link a{
  color: white;

@keyframes fadeIn{
  from{opacity: 0;}
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.