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

              
                .carousel
  .carousel-inner
    .item.active
      .container
        blockquote Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation.
        p.author Oscar Wilde
    .item
      .container
        blockquote Do something every day that you don't want to do. This is the golden rule for acquiring the habit of doing your duty without pain.
        p.author Mark Twain
    .item
      .container
        blockquote The worst sin towards our fellow creatures is not to hate them, but to be indifferent to them. That's the essence of inhumanity.
        p.author George Bernard Shaw
  .carousel-control.left
    .arrow.left
  .carousel-control.right
    .arrow.right
  ol.carousel-indicators
    li.active
    li
    li
              
            
!

CSS

              
                body {
  font-family: 'Montserrat', sans-serif;
  color: #FFFFFF;
  background-color: #1E88E5;
}

.carousel {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  padding: 90px 0;
  text-align: center;
  background-color: #1E88E5;
  transform: translate(-50%, -50%);
}

.carousel-inner {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.carousel-inner > .item {
  position: relative;
  display: none;
  animation: 0.5s ease-in-out;
}

.carousel-inner > .active,
.carousel-inner > .next {
  display: block;
}

.carousel-inner > .next {
  position: absolute;
  top: 0;
  width: 100%;
}

.carousel-inner > .to-left {
  animation-name: left;
}

.carousel-inner > .from-right {
  animation-name: right;
}

.carousel-inner > .to-right {
  animation-name: right;
  animation-direction: reverse;
}

.carousel-inner > .from-left {
  animation-name: left;
  animation-direction: reverse;
}

.container {
  margin: 0 auto;
}

blockquote {
  padding: 10px 20px;
  margin: 30px 90px;
  font-size: 32px;
}

.author {
  margin: 0;
  opacity: 0.5;
}

.carousel-control {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 15%;
  cursor: pointer;
}

.carousel-control.right {
  right: 0;
  left: auto;
}

.carousel-control > .arrow {
  position: absolute;
  top: 50%;
  display: inline-block;
  width: 30px;
  height: 30px;
  background: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjYiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyNiAyMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+QXJyb3c8L3RpdGxlPjxwYXRoIGQ9Ik0yNS42IDEwLjk3NGwtOC41MyA4LjYyYTEuMzYgMS4zNiAwIDAgMS0xLjkzNS4wMDMgMS4zODcgMS4zODcgMCAwIDEtLjAwMi0xLjk1bDYuMjAxLTYuMjY4SDEuMzY4QTEuMzc0IDEuMzc0IDAgMCAxIDAgMTBjMC0uNzYyLjYxMy0xLjM4IDEuMzY4LTEuMzhoMTkuOTY2bC02LjItNi4yNjdhMS4zODcgMS4zODcgMCAwIDEgLjAwMS0xLjk1IDEuMzYgMS4zNiAwIDAgMSAxLjkzNi4wMDJsOC41MyA4LjYyMWMuNTMyLjUzOC41MzIgMS40MSAwIDEuOTQ4IiBmaWxsPSIjRkZGRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=") center center no-repeat;
  background-size: 26px 20px;
  opacity: 0.6;
  transform: translateY(-50%);
}

.carousel-control > .arrow:hover {
  opacity: 0.8;
}

.carousel-control > .arrow.left {
  transform: translateY(-50%) rotate(180deg);
}

.carousel-control > .arrow.right {
  right: 50%;
}

.carousel-indicators {
  position: absolute;
  bottom: 20px;
  left: 50%;
  padding-left: 0;
  margin: 0;
  list-style: none;
  transform: translateX(-50%);
}

.carousel-indicators li {
  display: inline-block;
  width: 10px;
  height: 10px;
  cursor: pointer;
  border: 1px solid #FFFFFF;
  border-radius: 10px;
}

.carousel-indicators li.active {
  background-color: #FFFFFF;
}

@media (min-width: 992px) {
  .container {
    width: 970px;
  }
}

@media (min-width: 1200px) {
  .container {
    width: 1170px;
  }
}

@keyframes left {
  from {
    left: 0;
  }
  to {
    left: -100%;
  }
}

@keyframes right {
  from {
    left: 100%;
  }
  to {
    left: 0;
  }
}
              
            
!

JS

              
                var items = document.querySelectorAll('.carousel .item');
var dots = document.querySelectorAll('.carousel-indicators li');
var currentItem = 0;
var isEnabled = true;

function changeCurrentItem(n) {
	currentItem = (n + items.length) % items.length;
}

function nextItem(n) {
	hideItem('to-left');
	changeCurrentItem(n + 1);
	showItem('from-right');
}

function previousItem(n) {
	hideItem('to-right');
	changeCurrentItem(n - 1);
	showItem('from-left');
}

function goToItem(n) {
	if (n < currentItem) {
		hideItem('to-right');
		currentItem = n;
		showItem('from-left');
	} else {
		hideItem('to-left');
		currentItem = n;
		showItem('from-right');
	}
}

function hideItem(direction) {
	isEnabled = false;
	items[currentItem].classList.add(direction);
	dots[currentItem].classList.remove('active');
	items[currentItem].addEventListener('animationend', function() {
		this.classList.remove('active', direction);
	});
}

function showItem(direction) {
	items[currentItem].classList.add('next', direction);
	dots[currentItem].classList.add('active');
	items[currentItem].addEventListener('animationend', function() {
		this.classList.remove('next', direction);
		this.classList.add('active');
		isEnabled = true;
	});
}

document.querySelector('.carousel-control.left').addEventListener('click', function() {
	if (isEnabled) {
		previousItem(currentItem);
	}
});

document.querySelector('.carousel-control.right').addEventListener('click', function() {
	if (isEnabled) {
		nextItem(currentItem);
	}
});

document.querySelector('.carousel-indicators').addEventListener('click', function(e) {
	var target = [].slice.call(e.target.parentNode.children).indexOf(e.target);
	if (target !== currentItem && target < dots.length) {
		goToItem(target);
	}
});
              
            
!
999px

Console