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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


                <div class="wrapper">

  <div class="carousel">

    <button type="button" id="carousel-arrow-prev" class="carousel-arrow carousel-arrow-prev" arial-label="Image précédente"></button>
    <button type="button" id="carousel-arrow-next" class="carousel-arrow carousel-arrow-next" arial-label="Image suivante"></button>

    <img id="carousel-0" class="carousel-img carousel-img-displayed" src="" alt="Winter" />
    <img id="carousel-1" class="carousel-img carousel-img-noDisplay" src="" alt="Sea" />
    <img id="carousel-2" class="carousel-img carousel-img-noDisplay" src="" alt="Night" />
    <img id="carousel-3" class="carousel-img carousel-img-noDisplay" src="" alt="Moutain" />
    <img id="carousel-4" class="carousel-img carousel-img-noDisplay" src="" alt="Desert" />




                /* Container */

.wrapper {
  width: 800px;
  max-width: 100%;
  margin: auto;
  overflow: hidden;

.carousel {
  position: relative;
  width: 100%;
  height: 0;
  padding-top: 56.25%;
  background: #ddd;

/* Images */

.carousel-img {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 100%;
  -webkit-transition: opacity ease-out 0.5s;
  transition: opacity ease-out 0.5s;

.carousel-img-displayed {
  display: block;
  opacity: 1;
  z-index: 2;

.carousel-img-hidden {
  display: block;
  opacity: 0;
  z-index: 1;

.carousel-img-noDisplay {
  display: none;

/* Flèches de défilement */

.carousel-arrow {
  z-index: 3;
  display: block;
  position: absolute;
  width: 36px;
  height: 36px;
  top: 50%;
  margin-top: -18px;
  border-radius: 50%;
  border: 0;
  background-color: #fff;
  background-image: url("");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
  cursor: pointer;
  -webkit-transition: background-size 0.15s ease-out;
  transition: background-size 0.15s ease-out;

.carousel-arrow:focus {
  background-size: 22px 22px;

.carousel-arrow-next {
  right: 20px;

.carousel-arrow-prev {
  left: 20px;
  -webkit-transform: rotateZ(180deg);
  -ms-transform: rotate(180deg);
  transform: rotateZ(180deg);




 * Switch header carousel to next image (swipe right)
function carouselSwipe() {
    // Récupère les numéros de l'ancienne et la nouvelle image
    var currentImg = document.getElementsByClassName('carousel-img-displayed')[0].id.substring(9);
	var newImg = parseInt(currentImg);
    // Gestion du début et de la fin de la liste d'images
	if ( == 'carousel-arrow-next') {
        if (newImg >= document.getElementsByClassName('carousel-img').length) {
            newImg = 0;
	} else if ( == 'carousel-arrow-prev') {
        if (newImg<0) {
            newImg = document.getElementsByClassName('carousel-img').length-1;
	// Disparition progressive de l'ancienne image
    document.getElementById('carousel-'+currentImg).className = 'carousel-img carousel-img-hidden';
    // Apparition progressive de la nouvelle image
    var displayedCarousel = document.getElementById('carousel-'+newImg);
	displayedCarousel.className = 'carousel-img carousel-img-hidden';
	setTimeout(function() {
		displayedCarousel.className = 'carousel-img carousel-img-displayed';
    // Disparition totale de l'ancienne image
	setTimeout(function() {
		document.getElementById('carousel-'+currentImg).className = 'carousel-img carousel-img-noDisplay';