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

              
                <div class="container">
  
  <h1> Place holders </h1>
  
  <div class="carousel">
    
    <div class="arrow" data-dir="-1"> 
      ⟻
    </div>
    <div class="arrow" data-dir="1"> 
      ⟼
    </div>
    
      <div class="card card-on-left"
           data-pos="1">
        <img
             src="https://picsum.photos/400"
             alt="Lorem Picsum"
             class="illustration"
             >
        <p class="name">
          <a href="https://picsum.photos">
            Lorem Picsum
          </a>
        </p>
      </div>
      <div class="card card-on-right"
           data-pos="2">
        <img
             src="https://via.placeholder.com/400"
             alt="place holder"
             class="illustration"
             >
        <p class="name">
          <a href="https://via.placeholder.com">
            place holder
          </a>
        </p>
      </div>
      <div class="card card-on-left"
           data-pos="3">
        <img
             src="https://www.placecage.com/400/400"
             alt="place Cage"
             class="illustration"
             >
        <p class="name">
          <a href="https://www.placecage.com">
            place Cage
          </a>
        </p>
      </div>
      <div class="card card-on-right"
           data-pos="4">
        <img
             src="https://placekitten.com/400/400"
             alt="place Kitten"
             class="illustration"
             >
        <p class="name">
          <a href="https://placekitten.com">
            Place Kitten
          </a>
        </p>
      </div>
      <div class="card card-on-left"
           data-pos="5">
        <img
             src="https://baconmockup.com/400/400"
             alt="baconmockup"
             class="illustration"
             >
        <p class="name">
          <a href="https://baconmockup.com">
            baconmockup
          </a>
        </p>
      </div>
            <div class="card card-on-right"
                 data-pos="6">
        <img
             src="https://placebeard.it/400x400"
             alt="place beard"
             class="illustration"
             >
        <p class="name">
          <a href="https://placebeard.it">
            place beard
          </a>
        </p>
      </div>
            <div class="card card-on-left"
             data-pos="7">
        <img
             src="http://placeimg.com/400/400/arch/grayscale"
             alt="place img"
             class="illustration"
             >
        <p class="name">
          <a href="http://placeimg.com">
            Place img
          </a>
        </p>
      </div>
            <div class="card card-on-right"
             data-pos="8">
              <img
             src="https://www.fillmurray.com/400/400"
             alt="fill Murray"
             class="illustration"
             >
        <p class="name">
          <a href="https://www.fillmurray.com">
            fill Murray
          </a>
        </p>        
      </div>
    </div>
</div>

<a href="https://maxime-malfilatre.com" class="signature" target="_blank">
	<div class="link">
		<span class="brace">
			{
		</span>
		<span class="before">
			<span class="before-text">
				&nbsp;by
			</span>
		</span>
		<span class="my-name">
			m
		</span>
		<span class="after">
			<span class="after-text">
				<span class="spin">axe</span>
				<span>w</span>
			</span>
		</span>
		<span class="brace">
			}
		</span>
	</div>
</a>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Caveat:wght@600&family=Oswald&display=swap');

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

a{
  text-decoration: none;
  color: #222;
}

h1{
  font-family: Oswald;
  font-size: 15vmin;
}

body{
  color: #eee;
  overflow: hidden;
}

.container{
  height: 100vh;
  width: 100vw;
  background: radial-gradient(circle at 50vw 10vh, rgb(224, 172, 223), rgb(86, 96, 176));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
}

.carousel{
  position: relative;
  height: 75vh;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.arrow{
  position: absolute;
  top: 50%;
  font-size: 2rem;
  right: 7.5vw;
  cursor: pointer;
  width: 3.5rem;
  aspect-ratio: 1/.9;
  display:grid;
  place-content: center;
  border-radius: 50%;
  background: #eeeeee55;
}

.arrow:first-child{
  left: 7.5vw;
}

.arrow:hover{
  color: rgb(86, 96, 176);
  background: #eeeeeedd;
}

.card{
  position: absolute;
  height: 60vmin;
  width: 52vmin;
  transform-origin: bottom;
  transition: transform 1s ease-in-out;
  border: 1vmin solid black;
  background: #eee;
}


.card[data-pos='1']{
  z-index: 1;
}

.card[data-pos='2']{
  z-index: 2;
}

.card[data-pos='3']{
  z-index: 3;
}

.card[data-pos='4']{
  z-index: 4;
}

.card[data-pos='5']{
  z-index: 5;
}

.card[data-pos='6']{
  z-index: 6;
}

.card[data-pos='7']{
  z-index: 7;
}

.card[data-pos='8']{  
  z-index: 8;
}

.card-on-left{
  transform: translateX(calc(-50% - 50vw));
}

.card-on-right{
  transform: translateX(calc(50% + 50vw));
}

.card-centered[data-pos='1']{
  transform: rotate(5deg);
}

.card-centered[data-pos='2']{
  transform: rotate(10deg);
}

.card-centered[data-pos='3']{
  transform: rotate(5deg);
}

.card-centered[data-pos='4']{
  transform: rotate(0deg);
}

.card-centered[data-pos='5']{
  transform: rotate(-5deg);
}

.card-centered[data-pos='6']{
  transform: rotate(-10deg);
}

.card-centered[data-pos='7']{
  transform: rotate(-5deg);
}

.card-centered[data-pos='8']{  
  transform: rotate(0deg);
}

/* anim for moving cards from front to back */

.card[data-pos='9']{
  z-index: 9;
  animation: linear .5s forwards running to-the-back;
}

@keyframes to-the-back{

  25%{
    opacity: 0.75;
  }
  40%{
    transform: translateX(10vw)  rotate(30deg);
    opacity: 0;
    z-index: 9;
  }
  60%{
    transform: translateX(-15vw)  rotate(-45deg);
    opacity: 0;
  }
  75%{
    opacity: 0.75;
    z-index: 1;
  }
  100%{
    transform: translateX(0)  rotate(0);
    opacity: 1;
    z-index: 1;
  }
}

/* anim for moving cards from back to front */

.card[data-pos='0']{
  z-index: 0;
  animation: linear .5s forwards running to-the-front;
}

@keyframes to-the-front{
  25%{
    opacity: 0.75;
  }
  40%{
    transform: translateX(-15vw)  rotate(-45deg);
    opacity: 0;
    z-index: 1;
  }
  60%{
    transform: translateX(10vw)  rotate(30deg);
    opacity: 0;
  }
  75%{
    opacity: 0.75;
    z-index: 9;
  }
  100%{
    transform: translateX(0)  rotate(0);
    opacity: 1;
    z-index: 9;
  }
}

.illustration{
  width: 100%;
  height: auto;
  transition: transform .25s ease-in-out;
}

.name{
  text-align: center;
  font-size: 5vmin;
  font-family: caveat;
}

/* ===> SIGNATURE <=== */

.link {
	position: fixed;
	z-index: 10;
	left: calc(2.5vmin - 0.75rem);
	bottom: calc(2.5vmin - 0.75rem);
	font-size: 1.5rem;
	font-family: arial, sans-serif;
	color: whitesmoke;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
}

.my-name {
	position: relative;
}

.before,
.after {
	overflow: hidden;
	width: 0px;
	transition: width 0.5s;
	transform-origin: right;
}

.before-text {
	display: inline-block;
	width: auto;
	text-align: right;
}

.after-text {
	display: flex;
	align-items: center;
	width: auto;
	height: 3rem;
	transform-origin: top center;
}

.link:hover .before {
	width: 2.5rem;
}

.link:hover .after {
	width: 4rem;
}

.link:hover .spin {
	display: inline-block;
	transition: 0.5s transform 0.5s ease-in-out;
	transform: rotate(360deg);
}

              
            
!

JS

              
                const cards = [...document.querySelectorAll('.card')],
      container = document.querySelector('.container'),
      arrows = [...document.querySelectorAll('.arrow')]

let angle = 0,
    chgtCard = 0,
    canChange = true, //prevent spam
    prevX,
    prevY,
    timeElapsed = 50

window.onLoad = animateCards() 


// first card animation when the page is loaded
function animateCards(){  
  cards.forEach((card,idx) => {
    setTimeout(function(){
      
      let divClassName
      
      if(idx % 2 === 0) {
    divClassName = "card-on-left"
    }
      else{
    divClassName = "card-on-right"        
      }
      
      card.classList.remove(divClassName)
        setTimeout(function(){
          card.classList.add("card-centered")
        }, 150 + cards.length * 150)
    }, timeElapsed)
    
    timeElapsed += 150
  })
}


function changeCard(direction){
  // direction : -1 => left / 1 => right
  
  canChange = false
  cards.forEach(card => {
    
    let pos = parseInt(card.dataset.pos,10)    
    let formerPos = pos    
    pos += direction
        
    card.dataset.pos = pos
    
    if(pos === 0){
      setTimeout(function(){
        card.dataset.pos = 8
        canChange = true
      }, 500)
    }
    
    else if(pos === 9){
      setTimeout(function(){
        card.dataset.pos = 1
        canChange = true
      }, 500)
      
    }
  })
  

}


// -A- change cards with wheel
container.addEventListener('wheel', e  =>{
    
  if(canChange){
    const direction = Math.sign(e.deltaY)
    chgtCard += direction
    
    Math.abs(chgtCard) > 5 && (
      changeCard(direction),
      chgtCard = 0)
  }
})


// -B- change cards with touches
container.addEventListener('touchstart', (e) => {
  e.preventDefault()
  prevX = e.touches[0].clientX
  prevY = e.touches[0].clientY
})

container.addEventListener('touchmove', (e) => {
  e.preventDefault()
  if(canChange){
    let direction
    let newX = e.touches[0].clientX
    let newY = e.touches[0].clientY
    let deltaX = Math.abs(newX - prevX)
    let deltaY = Math.abs(newY - prevY)
    if(deltaX > 10 || deltaY > 10){
      deltaX > deltaY ? ( direction = Math.sign(newX - prevX),
        prevX = newX) 
      : (direction = Math.sign(newY - prevY),
        prevY = newY)
    changeCard(direction)
    }
  }
})


// -C- change cards with arrows
arrows.forEach(arrow => arrow.addEventListener('click', e => changeCard(parseInt(e.target.dataset.dir) )))


              
            
!
999px

Console