cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              This example is not mine, it belongs to this course --->
<a href="https://javascript30.com/">javascript30.com</a> 


Author <a href="https://twitter.com/wesbos">@Wes Bos</a>




<div class="panels">
  <div class="panel panel1">
    <p>Hey </p>
    <p>Let´s</p>
    <p>Dance</p>
  </div>
  <div class="panel panel2">
    <p>Give</p>
    <p>Take</p>
    <p>Recive</p>
  </div>
  <div class="panel panel3">
    <p>Experience</p>
    <p>It</p>
    <p>Today</p>
  </div>
  <div class="panel panel4">
    <p>Give</p>
    <p>All</p>
    <p>You</p>
  </div>
  <div class="panel panel5">
    <p>Life</p>
    <p>In</p>
    <p>Motions</p>
  </div>
</div>
            
          
!
            
              html {
  background: #ffc600;
  font-size: 20px;
  font-weight: 200;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

.panels {
  min-height: 100vh;
  overflow: hidden;
  display: flex;
}

.panel {
  background: #6b0f9c;
/*   box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.1); */
  color: #fff;
  text-align: center;
  transition: font-size 0.7s cubic-bezier(0.67, -0.19, 0.7, -0.11), flex 0.7s cubic-bezier(0.61, -0.19, 0.7, -0.11), backgrond 0.2s;
  font-size: 20px;
  background-size: cover;
  background-position: center;
  flex-grow: 1;
  justify-content: center;
  align-items:center;
  display: flex;
  flex-direction: column;
}

.panel1 {
  background-image: url(https://source.unsplash.com/user/erondu);
}

.panel2 {
  background-image: url(https://source.unsplash.com/user/ak96);
}

.panel3 {
  background-image: url(https://source.unsplash.com/user/r3dmax);
}

.panel4 {
  background-image: url(https://source.unsplash.com/user/nathananderson);
}

.panel5 {
  background-image: url(https://source.unsplash.com/user/aows);
}


/* Flex children */

.panel>* {
  margin: 0;
  width: 100%;
  transition: transform 0.5s;
  flex : 1 0 auto;
  display: flex;
  justify-content: center;
  align-items:center;
}

.panel> *:first-child {
  transform: translateY(-100%);
}

.panel.open-active > *:first-child {
  transform: translateY(0%);
}

.panel> *:last-child {
  transform: translateY(100%);
}

.panel.open-active> *:last-child {
  transform: translateY(0%);
}

.panel p {
  text-transform: uppercase;
  font-family: 'Amatic SC', cursive;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.75), 0 0 14px rgba(0, 0, 0, 0.75);
  font-size: 2em;
  cursor:pointer;
}

.panel p:nth-child(2) {
  font-size: 4em;
}

.panel.open {
  flex:5;
  font-size: 48px;
}

.cta {
  color: white;
  text-decoration: none;
}
            
          
!
            
              const panels = document.querySelectorAll('.panel');

function toggleOpen() {
  this.classList.toggle('open');
}

function toggleActive(e) {
  if(e.propertyName.includes('flex')) {
    this.classList.toggle('open-active');
  }
}

panels.forEach(panel => panel.addEventListener('click', toggleOpen));
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive))
            
          
!
999px
Loading ..................

Console