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

              
                <h1>Pure CSS Slideshow</h1>
<div class="container">
	<div class="slideshow">
		<div id="slide-1" class="slide">
			<a href="#slide-7"></a>
			<a href="#slide-2"></a>
			<img src="https://c1.staticflickr.com/9/8724/16310801553_cea90ae63d_n.jpg" />
		</div>
		<div id="slide-2" class="slide">
			<a href="#slide-1"></a>
			<a href="#slide-3"></a>
			<img src="https://c2.staticflickr.com/4/3719/19819674272_2384feaaf8_n.jpg" />
		</div>
		<div id="slide-3" class="slide">
			<a href="#slide-2"></a>
			<a href="#slide-4"></a>
			<img src="https://c2.staticflickr.com/2/1627/24319275501_3ec6f36fa7_n.jpg" />
		</div>
		<div id="slide-4" class="slide">
			<a href="#slide-3"></a>
			<a href="#slide-5"></a>
			<img src="https://c2.staticflickr.com/2/1460/25194537936_e3c54faefc_n.jpg" />
		</div>
		<div id="slide-5" class="slide">
			<a href="#slide-4"></a>
			<a href="#slide-6"></a>
			<img src="https://c2.staticflickr.com/2/1460/26216238325_9c425923a7_n.jpg" />
		</div>
		<div id="slide-6" class="slide">
			<a href="#slide-5"></a>
			<a href="#slide-7"></a>
			<img src="https://c2.staticflickr.com/8/7578/26194232483_8204bf119b_n.jpg" />
		</div>
		<div id="slide-7" class="slide">
			<a href="#slide-6"></a>
			<a href="#slide-1"></a>
			<img src="https://c2.staticflickr.com/8/7106/26862741906_d5283c42ba_n.jpg" />
		</div>
	</div>
  <div class="pagination">
    <a href="#slide-1"><span>1</span></a>
    <a href="#slide-2"><span>2</span></a>
    <a href="#slide-3"><span>3</span></a>
    <a href="#slide-4"><span>4</span></a>
    <a href="#slide-5"><span>5</span></a>
    <a href="#slide-6"><span>6</span></a>
    <a href="#slide-7"><span>7</span></a>
  </div>
</div>

<aside>

  <h2>About</h2>

  <p>I wanted to create a pure CSS image slideshow and this is the result.</p>

  <p>This slideshow was created using just CSS and HTML. Click anywhere on the left half to go to the previous slide, anywhere on the right half to go to the next slide. Oh and it loops in a carousel.</p>

  <p>There's pagination too so you can jump to any slide.</p>

  <h2>What could be improved?</h2>

  <ul>
    <li>Highlight the current slide in the pagination</li>
    <li>Prevent page jump when using pagination</li>
    <li>Automatically cycle through images</li>
  </ul>
  
</aside>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;600&display=swap');

body {
  background: linear-gradient(-45deg, #83a4d4, #b6fbff);
  font-family: 'Open Sans', sans-serif;
}

h1 {
  text-align: center;
}

h1,
aside,
.container {
  margin: 0 auto 20px;
  max-width: 500px;
}

.container {
  border-radius: 5px;
  margin: 0 auto;
  position: relative;
  transition: box-shadow 200ms;
  &:hover {
    box-shadow: 0 10px 50px -10px rgba(0,0,0,0.25);
  }
}
.slideshow {
	position: relative;
	width: 100%;
	&:after {
		content: '';
		display: block;
		padding-bottom: calc((100% / 6) * 4);
	}
	&:hover a {
		opacity: 1;
	}
	a {
		opacity: 0;
		position: relative;
		text-decoration: none;
		transition: opacity 0.5s;
		&:after {
			border-color: #FFF #FFF transparent transparent;
			border-style: solid;
			border-width: 2px;
			color: #FFF;
			display: block;
			height: 10px;
			position: absolute;
			top: calc(50% - 5px);
			width: 10px;
		}
		&:first-child:after {
			content: '';
			left: 10px;
			transform: rotate(-135deg);
		}
		&:nth-child(2):after {
			content: '';
			right: 10px;
			transform: rotate(45deg);
		}
	}
	.slide {
		background-color: #FFF;
		box-sizing: border-box;
		display: none;
		height: 100%;
		position: absolute;
		width: 100%;
		&:first-child,
		&:target {
			display: block;
		}
		a {
			display: block;
			height: 100%;
			position: absolute;
			width: 50%;
			&:nth-child(2) {
				left: 50%;
			}
		}
		img {
      border-radius: 5px;
			width: 100%;
		}
	}
}
.pagination {
  display: flex;
  bottom: 10px;
  justify-content: center;
  position: absolute;
  width: 100%;
  a {
    background: rgba(#FFF,0.75);
    border-radius: 50%;
    display: block;
    height: 10px;
    width: 10px;
    &:not(:last-child) {
      margin-right: 5px;
    }
    span {
      display: none;
    }
  }
}

a:target {
	color: red;
}
              
            
!

JS

              
                
              
            
!
999px

Console