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

+ 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

              
                <section class="testimonials">
  <div>
    <ul id="testimonials-ul">
      <li>
        <p>Hashtag bespoke YOLO, put a bird on it hammock polaroid wayfarers tattooed neutra squid lumbersexual meh humblebrag VHS. Cred tumblr cold-pressed messenger bag small batch trust fund, mustache next level. Keytar swag kogi viral waistcoat flexitarian.</p>
        <small>Some dude</small>
      </li>
      <li>
        <p>Readymade fashion axe chia, deep v photo booth gochujang jean shorts asymmetrical XOXO you probably haven't heard of them locavore heirloom kale chips dreamcatcher. </p>
        <small>Some guy</small>
      </li>
      <li>
        <p>Put a bird on it austin jean shorts direct trade cornhole, sriracha street art. Keytar craft beer kitsch polaroid, affogato tofu vinyl butcher.</p>
        <small>Some other guy</small>
      </li>
      <li>
        <p>Hashtag bespoke YOLO, put a bird on it hammock polaroid wayfarers tattooed neutra squid lumbersexual meh humblebrag VHS. Cred tumblr cold-pressed messenger bag small batch trust fund, mustache next level. Keytar swag kogi viral waistcoat flexitarian.</p>
        <small>Some dude</small>
      </li>
    </ul>
  </div>
  <div class="testimonials-control">
    <i class="fa fa-angle-left fa-2x" id="testimonials-l"></i>
    <i class="fa fa-angle-right fa-2x" id="testimonials-r"></i>
  </div>
</section>
              
            
!

CSS

              
                /* Dummy styles, don't copy these */

* {
  box-sizing: border-box;
}

body {
  font-family: 'Georgia', serif;
  font-style: italic;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
}

small {
  font-family: 'Montserrat', 'Helvetica', sans-serif;
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
}

/* Styles you want to copy across begin here */

.testimonials {
  background-color: #e8e8e5;
  overflow: hidden;
  width: 100%;
}

.testimonials ul {
  list-style: none;
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 0;
}

.testimonials ul li {
  display: inline-block;
  padding: 1rem;
  position: relative;
  text-align: center;
  width: 100vw;
}

.testimonials ul li p {
  max-width: 600px;
  margin: 1rem auto;
  width: 50%;
}

.testimonials-control {
  background-color: rgba(255,255,255,0.2);
  display: flex;
  justify-content: center;
}

.testimonials-control i {
  cursor: pointer;
  padding: 1.3rem;
}
              
            
!

JS

              
                // Get carousel elements

var tLeftButton = $("#testimonials-l");
var tRightButton = $("#testimonials-r");

// Get number of <li> elements in carousel

var tItemCount = document.getElementById('testimonials-ul').querySelectorAll('li').length;

// Set length based on that

var tWidth = tItemCount * 100 + "vw";
$(".testimonials ul").css("width", tWidth);

// Button functionality

var tPosition = 0;
console.log(tPosition);

tRightButton.click(function() {
  if (tPosition < (tItemCount - 1)) {
    tPosition++;
    var m = "-" + (100 * tPosition) + "vw";
    $(".testimonials ul").animate({
      "left": m
    }, 500);
    greyButton();
  }
});

tLeftButton.click(function() {
  if (tPosition > 0) {
    tPosition--;
    var m = "-" + (100 * tPosition) + "vw";
    $(".testimonials ul").animate({
      "left": m
    }, 500);
    greyButton();
  }
});

// Grey out buttons if not useable 

var greyButton = function() {
  if (tPosition == 0) {
    tLeftButton.css("opacity", "0.3");
    tLeftButton.css("cursor", "default");
  } else if (tPosition == (tItemCount - 1)) {
    tRightButton.css("opacity", "0.3");
    tRightButton.css("cursor", "default");
  } else {
    tRightButton.css("opacity", "1");
    tRightButton.css("cursor", "pointer");
    tLeftButton.css("opacity", "1");
    tLeftButton.css("cursor", "pointer");
  }
}

greyButton();

// And finally, if there's only one quote, kill the buttons altogether

if ( tItemCount == 1 ) {
  $('.testimonials-control').css('display','none');
}


              
            
!
999px

Console