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

              
                <div class="testimonial-carousel-container">
  <div class="header-title">
    <h2 class="title-text">Testimonials</h2>
    <p>See what our clients have to say about us</p>
  </div>
  <div class="carousel">
    <div class="prev">
      <svg viewBox="0 0 256 512" width="30" title="angle-left" fill="currentColor">
        <path d="M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z" />
      </svg>
    </div>
    
    <div class="testimonials">
      <div class="carousel-testimonial active">
        <div class="testimonial-initials">RM</div>
        <div class="testimonial-content">
          <div class="testimonial-name-and-location">
            <div class="testimonial-name">Ronald M</div>
            <div class="testimonial-location">McDonaldland</div>
          </div>
          <div class="testimonial-quote">Beef ribs chislic andouille, t-bone doner flank picanha hamburger chuck porchetta biltong swine. Shankle shank turducken ball tip doner.</div>
        </div>
      </div>
    
      <div class="carousel-testimonial activeRight">
        <div class="testimonial-initials">G</div>
        <div class="testimonial-content">
          <div class="testimonial-name-and-location">
            <div class="testimonial-name">Grimace</div>
            
          </div>
          <div class="testimonial-quote"> Cupim venison bacon ribeye pork loin, cow beef burgdoggen. Tenderloin cow pig, drumstick kielbasa pork chop chicken fatback swine ham hock spare ribs kevin t-bone.</div>
        </div>
      </div>
    
      <div class="carousel-testimonial">
        <div class="testimonial-initials">TH</div>
        <div class="testimonial-content">
          <div class="testimonial-name-and-location">
            <div class="testimonial-name">The Hamburglar</div>
            
          </div>
          <div class="testimonial-quote">Porchetta strip steak turkey capicola. Ham hock landjaeger venison, jowl tenderloin kielbasa doner turkey tri-tip meatloaf alcatra.</div>
        </div>
      </div>
    
      <div class="carousel-testimonial">
        <div class="testimonial-initials">MM</div>
        <div class="testimonial-content">
          <div class="testimonial-name-and-location">
            <div class="testimonial-name">Mayor McCheese</div>
            <div class="testimonial-location">McDonaldland</div>
          </div>
          <div class="testimonial-quote">Leberkas fatback burgdoggen frankfurter corned beef salami. Tenderloin pork chop bresaola, andouille cupim cow short loin. Alcatra capicola spare ribs kevin chicken, tri-tip tenderloin.</div>
        </div>
      </div>
    
      <div class="carousel-testimonial activeLeft">
        <div class="testimonial-initials">BE</div>
        <div class="testimonial-content">
          <div class="testimonial-name-and-location">
            <div class="testimonial-name">Birdie the Early Bird</div>
            <div class="testimonial-location">Giant Egg</div>
          </div>
          <div class="testimonial-quote">Chicken kielbasa strip steak spare ribs, porchetta turducken ribeye kevin jowl filet mignon meatloaf rump tail.</div>
        </div>
      </div>
    </div>
    <div class="next">
      <svg fill="currentColor" viewBox="0 0 256 512" width="30" title="angle-right">
        <path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z" />
      </svg>
    </div>
  </div>
  <!-- /* iterate nav */ -->
  <div class="testimonial-nav">
    <button class="testimonial-navitem active" aria-label="go to testimonial from Ronald M" onclick="gotoTestimonial(0)">
      <span>Ronald M</span>
    </button>
  
    <button class="testimonial-navitem" aria-label="go to testimonial from Grimace" onclick="gotoTestimonial(1)">
      <span>Grimace</span>
    </button>
  
    <button class="testimonial-navitem" aria-label="go to testimonial from The Hamburglar" onclick="gotoTestimonial(2)">
      <span>The Hamburglar</span>
    </button>
  
    <button class="testimonial-navitem" aria-label="go to testimonial from Mayor McCheese" onclick="gotoTestimonial(3)">
      <span>Mayor McCheese</span>
    </button>
  
    <button class="testimonial-navitem" aria-label="go to testimonial from Birdie the Early Bird" onclick="gotoTestimonial(4)">
      <span>Birdie the Early Bird</span>
    </button>
  </div>
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Lato:100,300,400,700,900,100italic,300italic,400italic,700italic,900italic);

* {
  margin: 0;
  padding: 0;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
  font-family: 'Lato', 'Helvetica Neue', sans-serif;
}

.testimonial-carousel-container {
  padding: 50px 0;
}
.testimonial-carousel-container .header-title {
  padding: 0 30px;
}
.testimonial-carousel-container .header-title h2,
.testimonial-carousel-container .header-title p {
  text-align: center;
}
.testimonial-carousel-container .header-title h2 {
  font-size: 40px;
  font-weight: 700;
}
.testimonial-carousel-container .header-title p {
  font-size: 30px;
}
.testimonial-carousel-container .carousel {
  display: flex;
  justify-content: center;
  margin: 66px 0 42px;
}
.testimonial-carousel-container .testimonials {
  display: flex;
  justify-content: center;
}
.testimonial-carousel-container .carousel-testimonial {
  display: none;
  flex-direction: column;
  align-content: center;
  justify-content: flex-start;
  min-height: 470px;
  max-width: 80%;
  padding: 40px;
  text-align: center;
  box-shadow: #00000029 0px 3px 6px;
  border-top: 100px solid #6C6C6C;
  background-color: #fff;
  transition: transform 0.25s;
}
.testimonial-carousel-container .carousel-testimonial.active {
  transform: scale(1.1);
  border-color: #219FD6;
  z-index: 1;
  display: flex;
  order: 2;
}
.testimonial-carousel-container .testimonial-content {
  display: flex;
  flex-direction: column-reverse;
  justify-content: space-between;
  height: 100%;
}
.testimonial-carousel-container .testimonial-initials {
  text-transform: uppercase;
  font-size: 48px;
  font-weight: bold;
  align-self: center;
  padding: 42px 0;
  margin-top: -115px;
  color: #6C6C6C;
  background-color: #fff;
  border: 2px solid #6C6C6C;
  border-radius: 50%;
  box-sizing: border-box;
  height: 150px;
  width: 150px;
}
.testimonial-carousel-container  .carousel-testimonial.active .testimonial-initials {
  color: #219FD6;
  border-color: #219FD6;
}
.testimonial-carousel-container .testimonial-name-and-location {
  margin-top: 17px;
}
.testimonial-carousel-container .testimonial-name {
  font-size: 22px;
  font-weight: bold;
}
.testimonial-carousel-container .testimonial-location {
  font-size: 18px;
  font-weight: 400;
  margin-top: 10px;
}
.testimonial-carousel-container .testimonial-quote {
  font-size: 16px;
  font-weight: 400;
  font-style: italic;
  line-height: 24px;
  margin: 20px 0;
}
.testimonial-carousel-container .carousel .prev,
.testimonial-carousel-container .carousel .next {
  display: none;
}
.testimonial-carousel-container .testimonial-nav {
  display: flex;
  justify-content: center;
  text-align: center;
}
.testimonial-carousel-container .testimonial-navitem {
  /* button reset */
  background: none;
	color: inherit;
	border: none;
	padding: 0;
	font: inherit;
	cursor: pointer;
	outline: inherit;
  /* testimonial-navitem styles */
  height: 12px;
  width: 12px;
  border-radius: 6px;
  margin: 10px;
  background-color: #F0F0F0;
  transition: all .25s;
}
.testimonial-carousel-container .testimonial-navitem:hover,
.testimonial-carousel-container .testimonial-navitem.active {
  background-color: #219FD6;
}
.testimonial-carousel-container .testimonial-navitem span {
  position: absolute !important; /* Outside the DOM flow */
  height: 1px; width: 1px; /* Nearly collapsed */
  overflow: hidden;
  clip: rect(1px 1px 1px 1px); /* IE 7+ only support clip without commas */
  clip: rect(1px, 1px, 1px, 1px); /* All other browsers */
}


/* desktop styles */
@media (min-width:990px)  {
  .testimonial-carousel-container .carousel .prev,
  .testimonial-carousel-container .carousel .next {
    display: block;
    color: #219FD6;
    margin: 30px;
    display: flex;
    cursor: pointer;
  }
  .testimonial-carousel-container .carousel-testimonial {
    width: 340px;
  }
  .testimonial-carousel-container .testimonial-content {
    flex-direction: column;
    justify-content: flex-start;
  }
  .testimonial-carousel-container .carousel-testimonial.activeLeft,
  .testimonial-carousel-container .carousel-testimonial.activeRight {
    display: flex;
  }
  .testimonial-carousel-container .carousel-testimonial.activeLeft {
    order: 1;
  }
  .testimonial-carousel-container .carousel-testimonial.activeRight {
    order: 3;
  }
  .testimonial-carousel-container .testimonial-navitem {
    width: 50px;
  }
  .testimonial-carousel-container .testimonial-navitem.active {
    width: 75px;
  }
}
              
            
!

JS

              
                var testimonialCarousel = document.querySelector('.testimonial-carousel-container');

if(testimonialCarousel) {
  var testimonials        = testimonialCarousel.getElementsByClassName('carousel-testimonial');
  var testimonialsDiv     = testimonialCarousel.querySelector('.testimonials');
  var testimonialNavitems = testimonialCarousel.getElementsByClassName('testimonial-navitem');
  var testimonialsArr     = [].slice.call(testimonials);
  var activeTestimonial   = 0;

  // add event listeners to prev and next
  testimonialCarousel.querySelector('.next').addEventListener('click', function() {
    nextTestimonial();
  });
  testimonialCarousel.querySelector('.prev').addEventListener('click', function() {
    prevTestimonial();
  });

  function initTestimonials() {
    // remove any active classes
    for(var i = 0; i < testimonialsArr.length; i++) {
      testimonialsArr[i].classList.remove('active');
      testimonialsArr[i].classList.remove('activeLeft');
      testimonialsArr[i].classList.remove('activeRight');
      testimonialNavitems[i].classList.remove('active');
    }
    // show/set active testimonials
    if(activeTestimonial == 0) {
      testimonialsArr[testimonialsArr.length - 1].classList.add('activeLeft');
    } else {
      testimonialsArr[activeTestimonial - 1].classList.add('activeLeft');
    }
    testimonialsArr[activeTestimonial].classList.add('active');
    if(activeTestimonial == testimonialsArr.length - 1) {
      testimonialsArr[0].classList.add('activeRight');
    } else {
      testimonialsArr[activeTestimonial + 1].classList.add('activeRight');
    }
    testimonialNavitems[activeTestimonial].classList.add('active');
    console.log("active index: " + activeTestimonial);
  }

  function nextTestimonial() {
    // increment active testimonial
    if (activeTestimonial < testimonialsArr.length - 1) {
      activeTestimonial++;
    } else {
      activeTestimonial = 0;
    }

    initTestimonials();
  }

  function prevTestimonial() {
    // decrement active testimonial
    if(activeTestimonial == 0) {
      activeTestimonial = testimonialsArr.length - 1;
    } else {
      activeTestimonial--;
    }

    initTestimonials();
  }

  function gotoTestimonial(index) {
    // update active testimonial
    activeTestimonial = index;

    initTestimonials();
  }

  initTestimonials();
}
              
            
!
999px

Console