Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <ul class="c-accordion">
 <li id="joker" class="c-accordion__item" style="--cover: url(https://i.pinimg.com/originals/1f/62/51/1f6251d4e9ab99d8bd84a4548a6f902e.jpg)">
  <a href="#joker" class="c-accordion__action">
   <div class="c-accordion__content">
    <h2 class="c-accordion__title c-accordion__title--hero c-accordion__title--hover-show">Jocker</h2>
     <p class="c-accordion__description">In Gotham City, mentally troubled comedian Arthur Fleck is disregarded and mistreated by society. He then embarks on a downward spiral of revolution and bloody crime. This path brings him face-to-face with his alter-ego: the Joker.</p>
   </div>
   <div class="c-accordion__aside">
    <h2 class="c-accordion__title c-accordion__title--hover-hide">Jocker</h2>
   </div>
  </a>
 </li>
 <li id="john-wick" class="c-accordion__item" style="--cover: url(https://media1.fdncms.com/clevescene/imager/u/original/30502117/johnwick.jpg)">
  <a href="#john-wick" class="c-accordion__action">
   <div class="c-accordion__content">
    <h2 class="c-accordion__title c-accordion__title--hero c-accordion__title--hover-show">John Wick</h2>
    <p class="c-accordion__description">
     John Wick is on the run after killing a member of the international assassins' guild, and with a $14 million price tag on his head, he is the target of hit men and women everywhere.
    </p>
   </div>
   <div class="c-accordion__aside">
    <h2 class="c-accordion__title c-accordion__title--hover-hide">John Wick</h2>
   </div>
  </a>
 </li>
 <li id="black-panther" class="c-accordion__item" style="--cover: url(https://cdn.vox-cdn.com/uploads/chorus_image/image/66412368/BlackPanther596d2f1e1f199.0.jpg)">
  <a href="#black-panther" class="c-accordion__action">
   <div class="c-accordion__content">
    <h2 class="c-accordion__title c-accordion__title--hero c-accordion__title--hover-show">Black Panther</h2>
    <p class="c-accordion__description">
     T'Challa, heir to the hidden but advanced kingdom of Wakanda, must step forward to lead his people into a new future and must confront a challenger from his country's past.
    </p>
   </div>
   <div class="c-accordion__aside">
    <h2 class="c-accordion__title c-accordion__title--hover-hide">Black Panther</h2>
   </div>
  </a>
 </li>
 <li id="marvel-captain" class="c-accordion__item" style="--cover: url(https://www.hqzona.com.br/wp-content/uploads/2020/05/captain-marvel-ss-main.jpg)">
  <a href="#marvel-captain" class="c-accordion__action">
   <div class="c-accordion__content">
    <h2 class="c-accordion__title c-accordion__title--hero c-accordion__title--hover-show">Marvel Captain</h2>
    <p class="c-accordion__description">
     Carol Danvers becomes one of the universe's most powerful heroes when Earth is caught in the middle of a galactic war between two alien races.
    </p>
   </div>
   <div class="c-accordion__aside">
    <h2 class="c-accordion__title c-accordion__title--hover-hide">Marvel Captain</h2>
   </div>
  </a>
 </li>
</ul>
              
            
!

CSS

              
                $component: '.c-accordion';

:root {
 font-family: 'Poppins', sans-serif;
 --color-primary: #3E66A0;
 
 
 --cover-placeholder: var(--color-primary);
}

body {
 padding: 0;
 margin: 0;
 height: 100vh;
}

#{$component} {
 list-style: none;
 padding: 0;
 margin: 0;
 height: 100%;
 display: flex;
 flex: 1 1 auto;
 overflow: hidden;
 &__item {
  --cover: var(--cover-placeholder);
  background: var(--cover);
  background-position: center center;
  background-size: cover;
  background-color: var(--cover-placeholder);
  background-blend-mode: luminosity;
  
  position: relative;
  flex-grow: 1;
  height: 100%;
  width: 100px;
  min-width: 2.05rem;
  transition: all .3s ease-in-out;
  
  &:hover, &:focus-within, &:target {
   _flex-grow: 2;
   width: 100%;
   background-color: transparent;
   #{$component} {
    &__title {
     &--hover-hide {
      max-height: 0;
      opacity: 0;
     }
     &--hover-show {
      opacity: 1;
     }
    }
    &__description {
     opacity: 1;
    }
   }
  }
  
  &:hover {
   cursor: pointer;
  }
 }
 &__action {
  position: absolute;
  display: flex;
  justify-content: center;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, .4);
  text-decoration: none;
 }
 &__title {
  color: white;
  margin: 0;
  max-height: 100%;
  transition: all .3s ease-in-out;
  overflow: hidden;
  &--hover-show {
   opacity: 0;
   width: 100%;
  }
  &--hero {
   font-size: 3rem;
   line-height: 150%;
  }
 }
 &__aside {
  padding: 1rem;
  position: absolute;
  height: 100%;
  right: 1rem;
  bottom: 0;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  &:before {
   content: '+';
   color: yellow;
   margin-bottom: 1rem;
   font-size: 2rem;
   display: inline-block;
  }
  &:after {
   content: '';
   flex-grow: 1;
   width: 1px;
   display: block;
   margin-top: 1rem;
   background-color: rgba(255, 255, 255, .2);
  }
 }
 &__content {
  padding: 2rem 2.5rem 0 2rem;
  width: 50%;
 }
 &__description {
  color: white;
  font-weight: 400;
  line-height: 120%;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
  opacity: 0;
  transition: all .3s ease-in-out;
 }
}
              
            
!

JS

              
                /*
 ** Inspiration/Based: https://dribbble.com/shots/6584063-Daily-UI-Accordion-Cards-Experiment
 */
              
            
!
999px

Console