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

              
                <!--
Slider Scaling Options, comment/uncomment the desired opening tag
Full: Fill parent element
Fixed: Predefined width and height, 600x400 for demo
Propotional: Scales to match parent width, 4x3, 5x4, and 16x9, and 1.35x 1
-->
<div class="slider slider--full">
<!-- <div class="slider slider--fixed"> -->
<!-- <div class="slider slider--proportional slider--proportional-16x9"> -->
	<div class="slider__inner">
		<input checked type="radio" name="slider__radiobox" id="slider__radiobox--1" class="slider__radiobox slider__radiobox--1"><label for="slider__radiobox--1" class="slider__radiobox-label slider__radiobox-label--item slider__radiobox-label--item-1"></label><label for="slider__radiobox--4" class="slider__radiobox-label slider__radiobox-label--prev slider__radiobox-label--prev-4"></label><label for="slider__radiobox--2" class="slider__radiobox-label slider__radiobox-label--next slider__radiobox-label--next-2"></label>
		<input         type="radio" name="slider__radiobox" id="slider__radiobox--2" class="slider__radiobox slider__radiobox--2"><label for="slider__radiobox--2" class="slider__radiobox-label slider__radiobox-label--item slider__radiobox-label--item-2"></label><label for="slider__radiobox--1" class="slider__radiobox-label slider__radiobox-label--prev slider__radiobox-label--prev-1"></label><label for="slider__radiobox--3" class="slider__radiobox-label slider__radiobox-label--next slider__radiobox-label--next-3"></label>
		<input         type="radio" name="slider__radiobox" id="slider__radiobox--3" class="slider__radiobox slider__radiobox--3"><label for="slider__radiobox--3" class="slider__radiobox-label slider__radiobox-label--item slider__radiobox-label--item-3"></label><label for="slider__radiobox--2" class="slider__radiobox-label slider__radiobox-label--prev slider__radiobox-label--prev-2"></label><label for="slider__radiobox--4" class="slider__radiobox-label slider__radiobox-label--next slider__radiobox-label--next-4"></label>
		<input         type="radio" name="slider__radiobox" id="slider__radiobox--4" class="slider__radiobox slider__radiobox--4"><label for="slider__radiobox--4" class="slider__radiobox-label slider__radiobox-label--item slider__radiobox-label--item-4"></label><label for="slider__radiobox--3" class="slider__radiobox-label slider__radiobox-label--prev slider__radiobox-label--prev-3"></label><label for="slider__radiobox--1" class="slider__radiobox-label slider__radiobox-label--next slider__radiobox-label--next-1"></label>

		<div class="slider__slides">
			<div class="slider__slide slider__slide--1"><img alt="Placeholder 940x470" src="http://placehold.it/940x470?text=940x470"></div>
			<div class="slider__slide slider__slide--2"><img alt="Placeholder 1200x600" src="http://placehold.it/1200x600?text=1200x600"></div>
			<div class="slider__slide slider__slide--3"><img alt="Placeholder 300x150" src="http://placehold.it/300x150?text=300x150"></div>
			<div class="slider__slide slider__slide--4"><img alt="Placeholder 800x400" src="http://placehold.it/800x400?text=800x400"></div>
		</div>
	</div>
</section>

              
            
!

CSS

              
                /** base */

*,
*:before,
*:after {
	box-sizing: border-box;
}

/** slider */

.slider {
	position: relative;
	max-width: 100%;
	max-height: 100%;
	margin: 0 auto;

	&:hover {

		.slider__radiobox-label--prev,
		.slider__radiobox-label--next {
			opacity: 1;
		}

		.slider__radiobox-label--prev { left:  6%; }
		.slider__radiobox-label--next { right: 6%; }
	}
	
	&--full {
		width: 100vw;
		height: 100vh;
	}

	&--fixed {
		width: 600px;
		height: 400px;
	}

	&--proportional {
		width: 100%;
		height: auto;
	}
}

.slider__inner {
	position: relative;
	margin: 0 auto;
	overflow: hidden;
	background: #ddd;
	
	.slider--full & {
		width: 100%;
		height: 100%;
	}

	.slider--fixed & {
		width: 100%;
		height: 100%;
	}

	.slider--proportional & {
		width: 100%;
		height: 0;
	}

	.slider--proportional-4x3 &  { padding-top: (3 /  4 * 100%); } // 4:3  = 75%
	.slider--proportional-5x4 &  { padding-top: (4 /  5 * 100%); } // 5:4  = 80%
	.slider--proportional-16x9 & { padding-top: (9 / 16 * 100%); } // 16:9 = 56.25%
}

.slider__slides {
	position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 1;
	width: (100% * 4);
	height: 100%;
	overflow-y: hidden;
	transition: margin-left 0.4s;
}

.slider__slide {
	display: block;
	float: left;
	position: relative;
	width: (100% / 4);
	height: 100%;

	img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}
}

.slider__radiobox-label {
	display: block;
	position: absolute; z-index: 2;
	cursor: pointer;

	&--item {
		bottom: 6%; left: 50%;
		transform: translateX(-50%);
		padding: 6px;
		border-radius: 50%;
		background: black;
		opacity: 0.3;
		transition: opacity 0.2s;

		&:hover {
			opacity: 0.5;
		}

		&--item-1 { margin-left: (12px * -3); }
		&--item-2 { margin-left: (12px * -1); }
		&--item-3 { margin-left: (12px * 1); }
		&--item-4 { margin-left: (12px * 3); }
	}

	&--prev,
	&--next {
		display: none;
		top: 50%;
		transform: translateY(-50%);
		height: 0;
		border: 10px solid black;
		border-top-color: transparent;
		border-bottom-color: transparent;
		opacity: 0;
		transition:
			left 0.2s,
			right 0.2s,
			opacity 0.2s;
	}

	&--prev { left:  -6%; border-left:  0; border-right-width: 17px; }
	&--next { right: -6%; border-right: 0; border-left-width:  17px; }
}

.slider__radiobox {
	display: none;

	&--1:checked ~ .slider__slides { margin-left:     0; }
	&--2:checked ~ .slider__slides { margin-left: -100%; }
	&--3:checked ~ .slider__slides { margin-left: -200%; }
	&--4:checked ~ .slider__slides { margin-left: -300%; }

	&--1:checked + .slider__radiobox-label--item-1,
	&--2:checked + .slider__radiobox-label--item-2,
	&--3:checked + .slider__radiobox-label--item-3,
	&--4:checked + .slider__radiobox-label--item-4 {
		opacity: 1;
	}

	&--1:checked ~ .slider__radiobox-label--prev-4,
	&--1:checked ~ .slider__radiobox-label--next-2,
	&--2:checked ~ .slider__radiobox-label--prev-1,
	&--2:checked ~ .slider__radiobox-label--next-3,
	&--3:checked ~ .slider__radiobox-label--prev-2,
	&--3:checked ~ .slider__radiobox-label--next-4,
	&--4:checked ~ .slider__radiobox-label--prev-3,
	&--4:checked ~ .slider__radiobox-label--next-1 {
		display: block;
	}
}

              
            
!

JS

              
                
              
            
!
999px

Console