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

              
                <section>
<h1>Edgar Allan Poe was an American writer, poet, editor, and literary critic.</h1>
<p>Poe is best known for his poetry and short stories, particularly his tales of mystery and the macabre. He is widely regarded as a central figure of Romanticism in the United States and of American literature as a whole, and he was one of the country's earliest practitioners of the short story.</p>

<!-- accordion items -->
<div class="unr-accordions">
  <div class="unr-accordion--wrapper">
    <h2 class="unr-accordion--heading">
      <button aria-expanded="false">
        <svg viewbox="0 0 10 10" width="24px" height="24px" aria-hidden="true" focusable="false">
          <rect class="vert" height="8" width="2" y="1" x="4" />
          <rect height="2" width="8" y="4" x="1" />
        </svg>
        The Black Cat (short story)
        
      </button>
    </h2>
    <div class="unr-accordion--panel" hidden>
      <p>It was first published in the August 19, 1843, edition of The Saturday Evening Post. In the story, an unnamed narrator has a strong affection for pets until he perversely turns to abusing them.</p>
    </div>
  </div>

  <div class="unr-accordion--wrapper">
    <h2 class="unr-accordion--heading">
      <button aria-expanded="false">
        <svg viewbox="0 0 10 10" width="24px" height="24px" aria-hidden="true" focusable="false">
          <rect class="vert" height="8" width="2" y="1" x="4" />
          <rect height="2" width="8" y="4" x="1" />
        </svg>
        
        The Cask of Amontillado
      </button>
    </h2>
    <div class="unr-accordion--panel" hidden>
      <p>First published in the November 1846 issue of Godey's Lady's Book. The story, set in an unnamed Italian city at carnival time in an unspecified year, is about a man taking fatal revenge on a friend who, he believes, has insulted him. Like several of Poe's stories, and in keeping with the 19th-century fascination with the subject, the narrative revolves around a person being buried alive – in this case, by immurement. As in "The Black Cat" and "The Tell-Tale Heart", Poe conveys the story from the murderer's perspective.</p>
    </div>
  </div>

  <div class="unr-accordion--wrapper">
    <h2 class="unr-accordion--heading">
      <button aria-expanded="false">
        <svg viewbox="0 0 10 10" width="24px" height="24px" aria-hidden="true" focusable="false">
          <rect class="vert" height="8" width="2" y="1" x="4" />
          <rect height="2" width="8" y="4" x="1" />
        </svg>
        
        The Gold-Bug
      </button>
    </h2>
    <div class="unr-accordion--panel" hidden>
      <p>The plot follows William Legrand, who was bitten by a gold-colored bug. His servant Jupiter fears that Legrand is going insane and goes to Legrand's friend, an unnamed narrator, who agrees to visit his old friend. Legrand pulls the other two into an adventure after deciphering a secret message that will lead to a buried treasure. </p>
    </div>
  </div>
</div>
<!-- end: accordion component -->
</section>
              
            
!

CSS

              
                :root {
  --blue-10: #E6E9EC;
  --blue-20: #CDD2D9;
  --blue-50: #828FA1;
  --blue-80: #364B68;
  --blue-100: #041E42;
}
html {
  font-family: Helvetica, sans-serif;
  color: var(--blue-100);
}
section {
  max-width: 920px;
  margin-top: 3em;
  margin-right: auto;
  margin-left: auto;
}

.unr-accordion--expandall {
  margin-bottom: 1em;
  border-radius: 5px;
  padding: 0.5em 1em;
  background-color: white;
}

.unr-accordion--expandall:hover,
.unr-accordion--expandall:focus {
  background-color: var(--blue-10);
}

.unr-accordion--wrapper {
  margin-bottom: 1em;
  border-top: 1px solid var(--blue-50);
  border-right: 1px solid var(--blue-50);
  border-bottom: 1px solid var(--blue-50);
  border-left: 3px solid var(--blue-50);
  /* border radius */
  border-radius: 3px;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
}

.unr-accordion--wrapper:last-child {
  border-bottom: 1px solid var(--blue-50);
  margin-bottom: 0;
}

.unr-accordion--wrapper > h2 {
  display: flex;
  margin: 0;
}

.unr-accordion--wrapper > h2 button {
  all: inherit;
    display: flex;
  justify-content: flex-start;
  align-items: center;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  border-top: 0;
  /* border radius */
  border-radius: 3px;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
  width: 100%;
  margin: 0;
  padding: 0.5em;
  font-size: 1.5rem;
  line-height: 1.5;
}

.unr-accordion--wrapper > h2 button:hover,
.unr-accordion--wrapper > h2 button:focus {
  background-color: var(--blue-10);
}

.unr-accordion--wrapper > h2 button:focus {
  outline: 2px auto highlight;
  outline: 2px auto -webkit-focus-ring-color;
  outline-offset: 2px;
}

.unr-accordion--wrapper > h2 button svg {
  font-size: 1rem;
  margin-right: 0.5em;
  flex-shrink: 0;
}

.unr-accordion--wrapper > h2 button[aria-expanded="true"] {
  background-color: white;
}

.unr-accordion--wrapper > h2 button[aria-expanded="true"] .vert {
  display: none;
}

.unr-accordion--wrapper > h2 button[aria-expanded] rect {
  fill: currentColor;
}

.unr-accordion--panel {
  margin-top: -1em;
  padding-top: 1em;
  padding-right: 1em;
  padding-bottom: 1em;
  /* padding left to account for wrapper panel */
  padding-left: 2.75rem;
  background-color: white;
}
              
            
!

JS

              
                (function () {
  const headings = document.querySelectorAll(".unr-accordion--heading");

  Array.prototype.forEach.call(headings, (h) => {
    let btn = h.querySelector("button");
    let target = h.nextElementSibling;

    btn.onclick = () => {
      let expanded = btn.getAttribute("aria-expanded") === "true";

      btn.setAttribute("aria-expanded", !expanded);
      target.hidden = expanded;
    };
  });
  
    var btns = document.querySelectorAll('.unr-accordion--heading>button');
  
    document.addEventListener('keydown', function(e){
      var direction = 0;
      var max = btns.length - 1;
      direction = (e.keyCode == 38) ? -1 : direction;
      direction = (e.keyCode == 40) ? 1 : direction;
      direction = (e.keyCode == 35) ? -999 : direction;
      direction = (e.keyCode == 36) ? 999 : direction;
      
      if(direction != ""){
         e.preventDefault();
        for(x = 0; x <= max; x++){
            if(document.activeElement == btns[x]){
              if(direction == -1 && x == 0 || direction == -999){
                  btns[max].focus();
                  break;
              }
              if(direction == 1 && x == max || direction == 999){
                  btns[0].focus();
                  break;
              }
              btns[x + direction].focus();
              break;
            }
        }
      }
      
      
    })
  
  
})();
              
            
!
999px

Console