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. 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


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.


                <section class="container">
  <div id="carousel">
    <figure style="background-color: lightGreen;">1</figure>
    <figure style="background-color: lightBlue;">2</figure>
    <figure style="background-color: lightYellow;">3</figure>
    <figure style="background-color: lightPink;">4</figure>
    <figure style="background-color: teal;">5</figure>
    <figure style="background-color: orange;">6</figure>
    <figure style="background-color: red;">7</figure>
    <figure style="background-color: babyBlue;">8</figure>
    <figure style="background-color: lightYellow;">9</figure>
    <figure style="background-color: grey;">10</figure>
    <figure style="background-color: pink;">11</figure>
    <figure style="background-color: turquoise;">12</figure>
    <figure style="background-color: orange;">13</figure>
<button id="left" class="click" data-num-frames='1'>Click left</button>
<button id="right" class="click" data-num-frames='1'>Click right</button>
<label for="rotate-carousel">x-axis-rotate</label> 
<input id="rotate-carousel" type="text" />   



                .container  {
  position: relative; 
  width: 210px;
  height: 140px;
  perspective: 1000px; 
  border: solid 2px lightGrey; 
  margin: 50px auto; 

#carousel  {
  position: absolute;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  transition: transform 1s;
  transform-style: preserve-3d;
  transform-origin: 105px;
  transition-timing-function: ease-in-out;

#carousel figure {
  margin: 0; 
  display: block;
  position: absolute; 
  height: 116px;
  left: 10px;
  top: 10px; 
  border: solid 2px black; 
  opacity: 0.8; 
  transition: transform 1s;



                $(document).ready(function() {
	// Panels Object
	var container = $('#carousel'),
    containerWidth = container.width(),
    panels = container.children('figure'),
		// no. of panels 
		panelCount = panels.length,
		// Width of each Panel 
		panelWidth = containerWidth,
		// Half the width of each panel - needed to calculate the offset from center
		panelHalfSize = (panelWidth / 2),
		// Defines the Y rotation of each panel 
		degreesRotation = 360 / panelCount,
		// Object to push our 
		tangentVariables = {},
		// Get our Tangent value 
		getTanDeg = function(deg) {
			var rad = deg * Math.PI / 180,
				degrees = Math.tan(rad);
			tangentVariables.degrees = degrees;
		// Call our tanget value function...
		callTangent = getTanDeg(20),
		//...and generate our offset. 
		centerOffset = panelHalfSize / tangentVariables.degrees,
		rotateCarouselDegrees = 0;
	// Rotate each of the panels on their Y Access. 
	var tempDegreesOffset = degreesRotation;
  var setPanels = function(){
    $(panels).each(function() {
        'width': panelWidth+'px',
        'transform': 'rotateY\(' + tempDegreesOffset + 'deg\) translateZ(' + centerOffset + 'px) rotateY(-'+tempDegreesOffset+'deg)'
      tempDegreesOffset = (tempDegreesOffset + degreesRotation);
	var advanceFrame = function(numFrames, direction) {
		if (direction === 'left') {
			rotateCarouselDegrees -= degreesRotation;
		} else {
			rotateCarouselDegrees += degreesRotation;
    var carousel = $('#carousel'),
        tempStyle = carousel.css('');

	$('').click(function() {
		var direction = $(this).attr('id'),
        numFrames = $(this).attr('data-num-frames');
    // Call our advanceFrames() function 
		advanceFrame(numFrames, direction);
  // $('input#rotate-carousel').keyup(function(){
  //   var value = $(this).val();
  //   $(container).css({
  //       'transform': 'rotateX('+value+'deg)'
  //   });
  // });