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

              
                <header id="slider">
		<a class= "logo-container" href="http://www.carlosvalencia.co"><img src="img/logoV2.svg"></a>
		<ul class= "nav-bar">
			<li><a href="#">Home</a></li>
			<li><a href="#">Contact</a></li>
			<li><a href="#">About</a></li>
		</ul>
		<ul class= "slider-nav">

		</ul>
		<div class="main-header-1 active">
			<div class="inner-header">
				<h1>Main Title</h1>
				<p>This is a pretty cool slider!</p>
				<a href="#">Portfolio</a>
			</div>
		</div>
		<div class="main-header-2">
			<div class="inner-header">
				<h1>My second Title</h1>
				<p>This is amazing</p>
				<a href="#">Contact me</a>
			</div>
		</div>
		<div class="main-header-3">
			<div class="inner-header">
				<h1>My third Title</h1>
				<p>This is awesome</p>
				<a href="#">Contact you</a>
			</div>
		</div>
		<div class="main-header-4">
			<div class="inner-header">
				<h1>My fourth Title</h1>
				<p>This is unbelievable</p>
				<a href="#">Contact us</a>
			</div>
		</div>
	</header>

              
            
!

CSS

              
                *{
	box-sizing: border-box;
}

html, body{
	margin: 0px;
	font-family: Arial, Tahoma, Sans-serif, Verdana, Helvetica;
}

#slider{
	background-color: black;
	height: 600px;
	position: relative;
	overflow: hidden;
	border-bottom: solid 2px gray;
}

.nav-bar{
	list-style-type: none;
	text-align: center;
	z-index: 10;
	position: absolute;
	top: 0px;
	left: 0px;
	right: 0px;
	padding: 0px;
}

.logo-container{
	position: absolute;
	left: 10px;
	top: 15px;
	z-index: 11;
}

.logo-container img{
	width: 90px;
}

.nav-bar li{
	display: inline-block;
	padding: 20px;
}

.nav-bar a{
	text-decoration: none;
	color: white;
	text-shadow: 2px 2px 5px black;
}

.slider-nav{
	list-style-type: none;
	text-align: center;
	z-index: 10;
	position: absolute;
	bottom: 0px;
	left: 50%;
	padding: 0px;
	-ms-transform: translateX(-50%);
    -webkit-transform: translateX(-50%);
	transform: translateX(-50%);
}

.slider-nav li{
	background-color: #009688;
	border-radius: 50px;
	height: 15px;
	width: 15px;
	display: inline-block;
	cursor: pointer;
	margin: 5px;
}

.slider-nav li.active-button{
	background-color: white;
}

[class^="main-header"]{
	background-size: cover;
	position: absolute;
	height: 600px;
	top: 0px;
	left: 0px;
	width: 100%;
	display: none;
	z-index: 0;
}

[class^="main-header"].active{
	display: block;
}

.main-header-1{
	background-image: url('https://unsplash.it/1200/800');
}

.main-header-2{
	background-image: url('https://unsplash.it/1250/850');	
}

.main-header-3{
	background-image: url('https://unsplash.it/1200/800');
}

.main-header-4{
	background-image: url('https://unsplash.it/1250/850');
}

.inner-header{
	text-align: center;
	position: relative;
	top: 50%;
	left: 50%;
	-ms-transform: translate(-50%,-50%);
    -webkit-transform: translate(-50%,-50%);
	transform: translate(-50%,-50%);
}

.inner-header h1{
	font-size: 3em;
	color: white;
	font-weight: 700;
	text-shadow: 2px 2px 3px black;
}

.inner-header p{
	color: lightblue;
	text-shadow: 2px 2px 3px black;
	font-size: 1.6em;
	font-weight: 400;
	font-family: 'PT Sans Narrow', Arial, Tahoma, Sans-serif, Verdana, Helvetica;
}

.inner-header a{
	padding: 10px;
	text-decoration: none;
	color: white;
	background-color: transparent;
	border: solid 2px white;
	display: inline-block;
}

.fade-in-top-bottom{
	-webkit-animation-name: fade-in-bottom;
	-webkit-animation-duration: 1.2s;
	animation-name: fade-in-bottom;
	animation-duration: 1.2s;
}

.fade-out-bottom-top{
	-webkit-animation-name: fade-out-top;
	-webkit-animation-duration: 1s;
	animation-name: fade-out-top;
	animation-duration: 1s;
}

.fade-in-bottom-top{
	-webkit-animation-name: fade-in-topss;
	-webkit-animation-duration: 1.2s;
	animation-name: fade-in-topss;
	animation-duration: 1.2s;
}

.fade-out-top-bottom{
	-webkit-animation-name: fade-out-bottomss;
	-webkit-animation-duration: 1s;
	animation-name: fade-out-bottomss;
	animation-duration: 1s;
}

.fade-in-left-right{
	-webkit-animation-name: fade-in-right;
	-webkit-animation-duration: 1.2s;
	animation-name: fade-in-right;
	animation-duration: 1.2s;
}

.fade-out-left-right{
	-webkit-animation-name: fade-out-right;
	-webkit-animation-duration: 1s;
	animation-name: fade-out-right;
	animation-duration: 1s;
}

/*
	WEBKIT ANIMATIONS
*/

@-webkit-keyframes fade-out-top{
	0%{opacity: 1;
		-webkit-transform: translateY(0px); 
		transform: translateY(0px);}
	100%{opacity: 0;
		-webkit-transform: translateY(-120px);
		transform: translateY(-120px);}
}

@-webkit-keyframes fade-in-bottom{
	0%{opacity: 0; 
		-webkit-transform: translateY(-120px);
		transform: translateY(-120px);}
	100%{opacity: 1; 
		-webkit-transform: translateY(0px);
		transform: translateY(0px);}
}

@-webkit-keyframes fade-in-topss{
	0%{opacity: 0; 
		-webkit-transform: translateY(60px);
		transform: translateY(60px);}
	100%{opacity: 1; 
		-webkit-transform: translateY(0px);
		transform: translateY(0px);}
}

@-webkit-keyframes fade-out-bottomss{
	0%{opacity: 1; 
		-webkit-transform: translateY(0px);
		transform: translateY(0px);}
	100%{opacity: 0; 
		-webkit-transform: translateY(120px);
		transform: translateY(120px);}
}

@-webkit-keyframes fade-in-right{
	0%{opacity: 0; 
		-webkit-transform: translateX(-100px);
		transform: translateX(-100px);}
	100%{opacity: 1;
		-webkit-transform: translateX(0px);
		transform: translateX(0px);}
}

@-webkit-keyframes fade-out-right{
	0%{opacity: 1; 
		-webkit-transform: translateX(0px);
		transform: translateX(0px);}
	100%{opacity: 0; 
		-webkit-transform: translateX(100px);
		transform: translateX(100px);}
}

/*
	END OF WEBKIT ANIMATIONS
*/

@keyframes fade-out-top{
	0%{opacity: 1; 
		transform: translateY(0px);}
	100%{opacity: 0;
		transform: translateY(-120px);}
}

@keyframes fade-in-bottom{
	0%{opacity: 0; 
		transform: translateY(-120px);}
	100%{opacity: 1; 
		transform: translateY(0px);}
}

@keyframes fade-in-topss{
	0%{opacity: 0; 
		transform: translateY(60px);}
	100%{opacity: 1; 
		transform: translateY(0px);}
}

@keyframes fade-out-bottomss{
	0%{opacity: 1; 
		transform: translateY(0px);}
	100%{opacity: 0; 
		transform: translateY(120px);}
}

@keyframes fade-in-right{
	0%{opacity: 0; 
		transform: translateX(-100px);}
	100%{opacity: 1;
		transform: translateX(0px);}
}

@keyframes fade-out-right{
	0%{opacity: 1; 
		transform: translateX(0px);}
	100%{opacity: 0; 
		transform: translateX(100px);}
}

/*
FIRST SECTION
*/

.first-section{
	background-color: #333333;
}

.section-container{
	padding-top: 15px;
	max-width: 1000px;
	margin: auto;
	text-align: center;
	background-color: transparent;
	color: white;
}

.card-container{
	width: 380px;
	height: 220px;
	display: inline-block;
	margin: 20px;
	
}

.card-1{
	background-color: #B70AA4;
	font-family: 'Lato', sans-serif;
}

.card-1 h2{
	font-weight: 900;
}

.card-1 h2 span{
	font-weight: 100;
}
.card-1 p{
	font-weight: 300;
}
.card-2{
	background-color: #2E821E;
	font-family: 'PT Sans Narrow', Sans-serif;
}

.card-3{
	background-color: #983C3C;
	font-family: 'Advent Pro', sans-serif;
}

.card-4{
	background-color: #28826C;
	font-family: 'Quicksand', sans-serif;
}


.clearfix:before,
.clearfix:after {
  content: "";
  display: table;
}

.clearfix:after {
  clear: both;
}

.clearfix {
  zoom: 1; /* ie 6/7 */
}

@media only screen and (min-width: 320px) and (max-width: 768px) {

	.card-container{
		width: 300px;
		height: 130px;
		margin: 10px;
	}
}
              
            
!

JS

              
                $(document).ready(function(){
	var Slider = function(opt){
		var slider = {};
		var currentSlide = 0;
		var nextSlide = 1;
		var sliderInterval;

		var _init = function(options){
			//recieve options, we need the -el- attribute
			slider.el = $(options.el); 
			slider.items = slider.el.find("[class^='main-header']");
			slider.sliderLength = slider.items.length;
			slider.offset = slider.el.children().length - slider.sliderLength;
			createNavigation();
			setSliderInterval();

		}

		var createNavigation = function(){
			//create the -buttons- to navigate between slides
			var ulSlider = slider.el.find('.slider-nav'); //position this where you want your navigation buttons to be
			var newLI = '<li></li>';
			var newLIActive = '<li class= "active-button"></li>';
			for (var i = 0; i< slider.sliderLength ; i++){
				if (i === 0){
					ulSlider.append(newLIActive);	
				}
				else{
					ulSlider.append(newLI);
				}
			}
			addEventListeners();
		};

		var addEventListeners = function(){
			// add event binders to the dynamically added li elements
			slider.el.find('.slider-nav').on('click', 'li', function() {
				//set this -> this will be the  to be the next slide, stop the function interval and start it again 
				nextSlide = $(this).index();
				clearInterval(sliderInterval);
				startSlider();
				setSliderInterval();
			});
		}

		var setSliderInterval = function(){
			sliderInterval = setInterval(startSlider, 4000);
		};

		var startSlider = function(){
			var mainDivs = slider.items;
			var ulSlider = slider.el.find('.slider-nav');
			//which slide comes next?
			if(nextSlide >= slider.sliderLength){
				nextSlide = 0;
				currentSlide = slider.sliderLength -1;
			}

			//animations using the eq selector
			//we first add the animation class, and then remove the previous one we don't want
			//toggle class, it results in an unwanted behaviour
			mainDivs.eq(currentSlide).find('h1').addClass('fade-out-bottom-top');
			mainDivs.eq(currentSlide).find('h1').removeClass('fade-in-top-bottom');

			mainDivs.eq(currentSlide).find('p').addClass('fade-out-left-right');
			mainDivs.eq(currentSlide).find('p').removeClass('fade-in-left-right');

			mainDivs.eq(currentSlide).find('a').addClass('fade-out-top-bottom');
			mainDivs.eq(currentSlide).find('a').removeClass('fade-in-bottom-top');

			mainDivs.eq(currentSlide).fadeOut('slow');

			mainDivs.eq(nextSlide).find('h1').addClass('fade-in-top-bottom');
			mainDivs.eq(nextSlide).find('h1').removeClass('fade-out-bottom-top');
			
			mainDivs.eq(nextSlide).find('p').addClass('fade-in-left-right');
			mainDivs.eq(nextSlide).find('p').removeClass('fade-out-left-right');

			mainDivs.eq(nextSlide).find('a').addClass('fade-in-bottom-top');
			mainDivs.eq(nextSlide).find('a').removeClass('fade-out-top-bottom');
			
			mainDivs.eq(nextSlide).delay(300).fadeIn('slow');

			//find offset of child elements to use their index to match the current slide with the selected button
			ulSlider.children().removeClass("active-button");
			ulSlider.children().eq(mainDivs.eq(nextSlide).index() - slider.offset).addClass("active-button");


			//update variables
			currentSlide = nextSlide;
			nextSlide += 1;
		};

		return {
			init: _init // reveal only the init function
		}
		
	}
	var headerSlider = new Slider();
	headerSlider.init({el: '#slider'});
});
              
            
!
999px

Console