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

              
                  <ul class="tabs">
  <li class="active">
    <h3><a id="responsive" href="javascript: document.querySelector('.tabs .active').classList.remove('active'); document.querySelector('#responsive').parentElement.parentElement.classList.add('active');">Responsive</a></h3>
    <div>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque iaculis metus est, at maximus metus pulvinar a. Proin scelerisque placerat orci, quis porta sapien aliquam id.</p>
    </div>
  </li>
  <li>
    <h3><a id="accessible" href="javascript: document.querySelector('.tabs .active').classList.remove('active'); document.querySelector('#accessible').parentElement.parentElement.classList.add('active');">Accessible</a></h3>
    <div>
      <p>Mauris tincidunt, velit nec iaculis rhoncus, lorem sapien feugiat lacus, sit amet pretium nisi augue ac nisi. Donec at rhoncus tellus, nec feugiat purus. Vestibulum elit odio, tincidunt ac ligula ut, commodo lacinia velit. Morbi cursus lorem eget vulputate facilisis. Praesent elementum lacus nec eros cursus finibus.</p>
    </div>
  </li>
  <li>
    <h3><a id="overscroll-ready" href="javascript: document.querySelector('.tabs .active').classList.remove('active'); document.querySelector('#overscroll-ready').parentElement.parentElement.classList.add('active');">Overscroll</a></h3>
    <div>
      <p>Phasellus ligula tortor, mollis non facilisis ac, pretium id quam. Vestibulum tristique lacus ac libero suscipit, quis cursus quam condimentum. Ut bibendum justo aliquet, mattis eros id, venenatis turpis. Aenean at tortor ac sem hendrerit fringilla in vel magna. Mauris a tellus ullamcorper, lobortis ligula et, blandit augue.</p>
    </div>
  </li>
</ul>
  
              
            
!

CSS

              
                body, html {height: 100%; margin: 0; padding: 0;}
body {display: flex; font-family: sans-serif; line-height: 1.4;}

.tabs {margin: auto; padding: 0; max-width: 50rem; position: relative; border-radius: 1rem;}
.tabs li {list-style: none;}
.tabs li > div {padding: 0 1.5rem 0 2.35rem; color: rgb(31, 20, 26); display: none;}
.tabs li.active > div {display: block;}
.tabs li > h3 {font-size: 1rem; margin: 0; padding: 0 1.5rem; position: relative;} 
.tabs li > h3 a {color: inherit; text-decoration: none; display: block; width: 100%; cursor: text; outline-color: rgb(255, 20, 146); cursor: pointer; color: rgb(107, 97, 102); padding: 0.5rem 0; border: 1px dotted transparent;}
.tabs li p {margin: 0 0 2rem;}
.tabs li.active > h3 {color: rgb(31, 20, 26);}
.tabs li.active > h3 a {margin-bottom: 0.5rem; color: black;}
.tabs li > h3 a::before {content: "›"; margin-right: 0.5rem; color: #ff1492;}
.tabs li > h3 a:hover {background: rgba(255, 20, 146, 0.05);}
.tabs li > h3 a:focus {outline: none; border: 1px dotted black;}

@media (min-width: 576px) {
  .tabs {padding-top: 4rem; box-shadow: 0px 0px 1rem rgba(0,0,0,0.15); }
  .tabs li {margin: 0;}
  .tabs li > div {padding: 0.75rem 1.5rem 0.5rem 1.5rem; min-height: 8rem}
  .tabs li > h3 {position: absolute; top: 0rem; text-align: center; margin: 0; padding: 0; border: 0;}
  .tabs li:first-child h3 a {border-top-left-radius: 1rem;}
  .tabs li:nth-child(2) > h3 {margin-left: 9.3rem;}
  .tabs li:nth-child(3) > h3 {margin-left: 18.6rem;}
  .tabs li.active > h3 {border-bottom: 2px solid #ff1492;}
  .tabs li > h3 a {padding: 1rem 0 1rem!important; margin-bottom: 0!important; width: 9.3rem;}
  .tabs li > h3 a::before {content: none;}
}
              
            
!

JS

              
                /*

Hi Adam, 

Your CSS and JS wizardry is amazing! Thank you for that. I immediately got a lot of different questions though:

- Do you really need all that fancyness? 
- What does the kebab do? 
- Aren't these tabs just the headers? 
- Is this still readable without CSS? 
- Do you actually need javascript for tabs?

I illustrated how I would build a tabs component and how I would simplify its view on mobile. My tabs have very little javascript, they are fully responsive and are fully accessible (try tabbing). The only downside could be that the links are mistaken by (users of) screen readers for actual useful/interesting links. I do not (yet) know how to solve that. Do you?

I am looking forward to your next GUI challenge. Have a great day!

https://web.dev/shows/gui-challenges/mMBcHcvxuuA/

*/
              
            
!
999px

Console