css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1>Responsive Accordion</h1>
<div class="accordion">
  <ul>
    <li tabindex="1">
      <div>
        <a href="#">
          <h2>Lorem Ipsum</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
        </a>
      </div>
    </li>
    <li tabindex="2">
      <div>
        <a href="#">
          <h2>Lorem Ipsum</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
        </a>
      </div>
    </li>
    <li tabindex="3">
      <div>
        <a href="#">
          <h2>Lorem Ipsum</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
        </a>
      </div>
    </li>
    <li tabindex="4">
      <div>
        <a href="#">
          <h2>Lorem Ipsum</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
        </a>
      </div>
    </li>
    <li tabindex="5">
      <div>
        <a href="#">
          <h2>Lorem Ipsum</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
        </a>
      </div>
    </li>
    <li tabindex="6">
      <div>
        <a href="#">
          <h2>Lorem Ipsum</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
        </a>
      </div>
    </li>
  </ul>
</div>
<p class="about">
  By <a href="http://michaelferry.com/">Michael Ferry</a>
</p>
            
          
!
            
              // Fonts
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
@import url(https://fonts.googleapis.com/css?family=Montserrat:700);

// Accordion Height
$a-height: 250px;

// Position text along bottom
$text-offset: $a-height - 90;

// Page Title
h1 {
  
  text-align:center;
  font-family:Montserrat,sans-serif;
  color:#333;

}

.accordion {

  width:100%;
  max-width:1080px;
  height:$a-height;
  overflow:hidden;
  margin:50px auto;

  ul {

    width:100%;
    display:table;
    table-layout:fixed;
    margin:0;
    padding:0;

    li {

      display:table-cell;
      vertical-align:bottom;
      position: relative;
      width:16.666%; // 6 into 100
      height:$a-height;

      background-repeat:no-repeat;
      background-position:center center;

      transition:all 500ms ease;

      div {
        
        display:block;
        overflow:hidden;
        width:100%;

        a {
          
          display:block;
          height:$a-height;
          width:100%;

          position:relative;
          z-index:3;
          vertical-align:bottom;
          padding:15px 20px;
          box-sizing:border-box;
          color:#fff;
          text-decoration:none;
          font-family:Open Sans, sans-serif;
          
          transition:all 200ms ease;

          * {

            opacity:0;
            margin:0;
            width:100%;
            text-overflow:ellipsis;
            position:relative;
            z-index:5;
            
            white-space:nowrap;
            overflow:hidden;
            
            -webkit-transform:translateX(-20px);
            transform:translateX(-20px);

            -webkit-transition:all 400ms ease;
            transition:all 400ms ease;

          }

          h2 {

            font-family:Montserrat,sans-serif;
            text-overflow:clip;
            font-size:24px;
            text-transform:uppercase;
            margin-bottom:2px;
            
            top:$text-offset;

          }
          
          p {
            
            top:$text-offset;
            font-size:13.5px;
            
          }

        }

      }

    }
    
    // Background images
    li:nth-child(1) { background-image:url('http://michael-ferry.com/assets/accordion1.jpg'); }
    li:nth-child(2) { background-image:url('http://michael-ferry.com/assets/accordion2.jpg'); }
    li:nth-child(3) { background-image:url('http://michael-ferry.com/assets/accordion3.jpg'); }
    li:nth-child(4) { background-image:url('http://michael-ferry.com/assets/accordion4.jpg'); }
    li:nth-child(5) { background-image:url('http://michael-ferry.com/assets/accordion5.jpg'); }
    li:nth-child(6) { background-image:url('http://michael-ferry.com/assets/accordion6.jpg'); }

    &:hover li,
    &:focus-within li { width:8%; }
    
    li:focus {
      outline: none;
    }

    &:hover li:hover,
    // allow users to tab through active slides
    li:focus,
    &:focus-within li:focus {

      width:60%;

      a {
        
        background:rgba(0,0,0,.4);
        
        * {
          
          opacity:1;
          -webkit-transform:translateX(0);
          transform:translateX(0);
        
        }
      
      }

    }
    
    &:hover li {
      width: 8% !important;
      
      a * { opacity: 0 !important; }
    }
    
    &:hover li:hover {
      width:60% !important;

      a {
        
        background:rgba(0,0,0,.4);
        
        * {
          
          opacity:1 !important;
          -webkit-transform:translateX(0);
          transform:translateX(0);
        
        }
      
      }
    }

  }

}

// Stack items
@media screen and (max-width: 600px) {
  
  // IE gets fussy if this isn't here
  body { margin:0; }
  
  .accordion {
    
    height:auto;
    
    ul,ul:hover {
      
      li,li:hover {
        
        position:relative;
        display:table;
        table-layout:fixed;
        width:100%;
        
        -webkit-transition:none;
        transition:none;
        
      }
      
    }
    
  }

}

.about {
  
  text-align:center;
  font-family:'Open Sans', sans-serif;
  font-size:12px;
  color:#666;
  
  a {
    
    color:blue;
    text-decoration:none;
    
    &:hover { text-decoration:underline; }
    
  }
  
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console