cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <div class="panels">
  <div class="panel panel1">
    <p>I'm</p>
    <p>Hello</p>
    <p>Yoshihiko</p>
  </div>
  <div class="panel panel2">
    <p>Dancing</p>
    <p>Let's</p>
    <p>Together!!</p>
  </div>
  <div class="panel panel3">
    <p>Show</p>
    <p>Thanks</p>
    <p>Me</p>
  </div>
  <div class="panel panel4">
    <p>I am</p>
    <p>Always</p>
    <p>Happy!!</p>
  </div>
  <div class="panel panel5">
    <p>Have a</p>
    <p>Goodbye</p>
    <p>Nice day!!</p>
  </div>
</div>
            
          
!
            
              body {
  margin: 0;
}

.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:white;
  text-align: center;
  align-items:center;
/*   ここのtransitionがopenクラスを付与した時のポイントとなる部分。 */
  transition:
    font-size 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
    flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11),
    background 0.2s;
  font-size: 20px;
  background-size:cover;
  background-position:center;
  flex: 1;
  justify-content: center;
  display: flex;
  flex-direction: column;
}


.panel1 { background-image:url(http://1.bp.blogspot.com/-aC2jXDBJcuY/VpjBp16ShbI/AAAAAAAA25w/pL6seXQvsM0/s1600/bg_natural_sougen.jpg); }
.panel2 { background-image:url(http://4.bp.blogspot.com/-8eVWfvvNu2E/V9vBHI-5lDI/AAAAAAAA92M/fNk7xdy6kME1_cUEWcXBIkX39vAn3daZwCLcB/s2000/bg_music_live_stage.jpg); }
.panel3 { background-image:url(http://1.bp.blogspot.com/-HDIqW5OPyGw/VtR8keHJi6I/AAAAAAAA4Qc/wU2w_ApPhSk/s1600/bg_sabaku.jpg); }
.panel4 { background-image:url(http://3.bp.blogspot.com/-dO-pdRfLT-E/V8jqV3zqiUI/AAAAAAAA9dI/-ggjHn6j_xM1GeDPqqZS8ThQBr8bZitzQCLcB/s2000/bg_doujou.jpg); }
.panel5 { background-image:url(http://1.bp.blogspot.com/-xkFdFkjkt6E/VpjBqm4-vEI/AAAAAAAA26M/69G2fAaMFy0/s1600/bg_outside_jutaku_yoru.jpg); }

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

/* translateYで1番目と3番目の要素を上下に逃してる。jsでクラスを追加することでtransformで元の位置に。 */
.panel > *:first-child {
  color: #ad3530;
  transform: translateY(-100%); 
}
.panel.open-active > *:first-child { transform: translateY(0); }

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

.panel p {
  text-transform: uppercase;
  font-size: 2em;
}
/* 2番目の子要素の文字サイズを指定 */
.panel p:nth-child(2) {
  font-size: 4em;
}
/* openクラスがあたったときの処理で、flexのグリットを拡大させることで他のものより大きく見せることができる。 */
.panel.open {
  flex: 5;
  font-size:40px;
}
            
          
!
            
              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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console