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

              
                <div class="container">
<h2>CSS Tab</h2>
<p>
  This pen uses radio buttons with opacity set to 0 as the toggles for the tabs.
</p>
  
<ul class="tabs">  
  <!-- Tab 1 -->
  <li class="tab-item">
    <div class="tab">
      <!-- Tab switcher -->
      <input type="radio" name="tab" value="tab1" checked>
      <h3 class="label orange">Tab 1</h3>
      <div class="tab-content">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus commodo gravida est. Proin mattis tristique tortor, quis ultrices ante condimentum quis. Duis mattis ultrices urna, sed aliquam neque suscipit vitae. Maecenas non interdum tortor. Integer ac nunc malesuada, viverra tortor quis, viverra dui. Etiam quis elementum eros. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus convallis suscipit risus non accumsan. Aenean quis nulla vehicula, lacinia orci ut, commodo massa.</p>
      </div>
    </div>
  </li>
  <!-- END Tab 1 -->
  
  <!-- Tab 2 -->
  <li class="tab-item">
    <div class="tab">
      <!-- Tab switcher -->
      <input type="radio" name="tab" value="tab1">
      <h3 class="label blue">Tab 2</h3>
      <div class="tab-content">
        <p>Nullam massa turpis, sollicitudin et fringilla sed, vestibulum sed justo. Fusce vel congue metus. Vivamus dapibus imperdiet leo, eu scelerisque risus sagittis eu. Nulla faucibus sed nunc quis sollicitudin. Curabitur tempor justo vitae sem volutpat placerat. Duis eu lorem id eros accumsan sollicitudin. Nullam eleifend vulputate est, id dapibus ligula aliquet vel. Nam mi lorem, fermentum non eros sit amet, aliquam volutpat nisl. Aliquam quis mi id dolor pharetra vulputate id ut lectus. Fusce ac ultricies nisi. Aliquam elementum eros a massa malesuada ultrices. Vestibulum feugiat tellus sit amet dui scelerisque, vitae dictum dui malesuada. Mauris tempor volutpat bibendum. Curabitur malesuada risus at lobortis porttitor. Cras sollicitudin bibendum turpis, nec dapibus mi.</p>
      </div>
    </div>
  </li>
  <!-- END Tab 2 -->
  
  <!-- Tab 3 -->
  <li class="tab-item">
    <div class="tab">
      <!-- Tab switcher -->
      <input type="radio" name="tab" value="tab1">
      <h3 class="label yellow">Tab 3</h3>
      <div class="tab-content">
        <p>Sed tempus mauris et metus tempus suscipit id eu leo. Phasellus in risus posuere, condimentum arcu quis, molestie lacus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus sit amet orci convallis turpis tincidunt elementum eget venenatis lorem. Nunc faucibus dictum magna vel imperdiet. Maecenas fermentum condimentum leo sed eleifend. Phasellus tristique porta venenatis. Donec sit amet suscipit odio. Cras vel tempus felis, eget accumsan turpis. Nam ultrices enim ac placerat porttitor.</p>
      </div>
    </div>
  </li>
  <!-- END Tab 3 -->
  
  <!-- Tab 4 -->
  <li class="tab-item">
    <div class="tab">
      <!-- Tab switcher -->
      <input type="radio" name="tab" value="tab1">
      <h3 class="label green">Tab 4</h3>
      <div class="tab-content">
        <p>Ut nec elit magna. Mauris turpis mi, iaculis quis sapien interdum, bibendum aliquam diam. Etiam blandit id tellus sit amet laoreet. Proin a cursus ante. Nullam rhoncus mauris rhoncus, fringilla turpis at, suscipit lorem. Curabitur dolor justo, aliquet eu vulputate ac, faucibus in mi. Morbi malesuada id nisl eu porttitor. Nunc nisl diam, gravida vitae feugiat ac, dictum eu tortor. Quisque id sem ornare, ullamcorper nisl at, aliquet turpis. In at magna in justo porta convallis. Vivamus in neque tortor. Cras bibendum ante quis ligula gravida, et ultrices erat consequat. Nunc sed turpis urna. Vivamus tempus molestie enim et lacinia. Nullam porttitor, mi elementum gravida euismod, est lorem gravida libero, quis ornare metus tellus ac elit.</p>
      </div>
    </div>
  </li>
  <!-- END Tab 4 -->

</ul>
</div>
              
            
!

CSS

              
                /* Import the Google Font 'Open Sans' */
@import url(https://fonts.googleapis.com/css?family=Open+Sans);


/* All widths and heights are calculated using the border box */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Positioning and layout of containers */
body {
  background-color: #333333;
}

.container {
  font-family: Open Sans, Helvetica, Arial, sans-serif;
  font-size: 16px;
  width: 800px;
  height: 500px;
  padding: 25px 50px;
  margin: 50px auto;
  box-shadow: 1px 1px 1px 1px rgba(100, 100, 100, 0.25);
  background-color: white;
}

.tabs {
  list-style: none;
  padding: 0;
  width: 650px;
  margin: 0 auto;
}

.tab-item {
  display: inline-block;
  margin-left: -5px;
}

.tab {
  position: absolute;
}

.tab > input[type=radio] {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: 150px;
  height: 50px;
  margin: 0;
  background-color: transparent;
  outline: none;
  z-index: 1;  
}

.label {
  display: inline-block;
  position: absolute;
  top: 0;
  left: 0;
  width: 150px;
  margin: 0;
  border-left: 1px solid rgba(100, 100, 100, 0.5);
  text-align: center;
  line-height: 50px;
  background-position: 0 3px;
  background-repeat: no-repeat;
  background-size: 25px;
  transition: background-position 250ms, color 250ms;
  z-index: 0;
}

.label::before {
  content: '';
  position: absolute;
  top: 0;
  left: -1px;
  width: 150px;
  height: 3px;
}

.label::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 147px;
  height: 2px;
  background-color: transparent;
}

.tabs .tab-item:last-child .label::after {
    width: 146px;
}

/* In Firefox some width values need to be slightly different */
@-moz-document url-prefix() {
  .label::before {
    width: 155px;
  }
  
  .label::after {
    width: 152px;
  }
  
  .tabs .tab-item:last-child .label::before {
    width: 150px;
  }
  
  .tabs .tab-item:last-child .label::after {
    width: 146px;
  }
}
/* END Positioning and layout of containers */


/* Colors, graphics and positioning for tabs */
.label.orange {
  background-image: url(https://dl.dropboxusercontent.com/s/68gv23q4y5qyq52/html5.svg);
}

.label.blue {
  background-image: url(https://dl.dropboxusercontent.com/s/gftbpqje9h2jvlv/css3.svg);
}

.label.yellow {
  background-image: url(https://dl.dropboxusercontent.com/s/jsp3rsberc4q650/javascript.svg);
}

.label.green {
  background-image: url(https://dl.dropboxusercontent.com/s/v28zws1p38tjph2/node.png);
}

.label.orange::before {
  background-color: #e34f26;
}

.label.blue::before {
  background-color: #0d84ce;
}

.label.yellow::before {
  background-color: #f0e040;
}

.label.green::before {
  background-color: #83cd29;
}

.tabs .tab-item:last-child .label {
  border-right: 1px solid rgba(100, 100, 100, 0.5);;
}

.tabs .tab-item:nth-child(2) input[type=radio],
.tabs .tab-item:nth-child(2) .label{
  left: 150px;
}
.tabs .tab-item:nth-child(2) .tab-content {
  left: 1px;
}

.tabs .tab-item:nth-child(3) input[type=radio],
.tabs .tab-item:nth-child(3) .label{
  left: 300px;
}

.tabs .tab-item:nth-child(3) .tab-content {
  left: 2px;
}

.tabs .tab-item:nth-child(4) input[type=radio],
.tabs .tab-item:nth-child(4) .label{
  left: 450px;
}

.tabs .tab-item:nth-child(4) .tab-content {
  left: 3px;
}

.tab > input[type=radio]:checked ~ .label::after {
  background-color: white;
}

.tab > input[type=radio]:checked ~ .label {
  color: #975997;
  background-position: 12.5px 50%;
}

.tab > input[type=radio]:checked ~ .label.orange {
  color: #e34f26;
  background-image: url(https://dl.dropboxusercontent.com/s/68gv23q4y5qyq52/html5.svg);
}

.tab > input[type=radio]:checked ~ .label.blue {
  color: #0d84ce;
}

.tab > input[type=radio]:checked ~ .label.yellow {
  color: #f0e040;
}

.tab > input[type=radio]:checked ~ .label.green {
  color: #83cd29;
}

.tab > input[type=radio]:checked ~ .tab-content p {
  top: 0;
}

.tab > input[type=radio]:not(:checked) ~ .tab-content p {
  top: 300px;
}

.tab-content {
  position: absolute;
  top: 50px;
  width: 650px;
  height: 265px;
  padding: 0 20px;
  overflow: hidden;
}

.tabs .tab-item:first-child .tab-content{
  border: 1px solid rgba(100, 100, 100, 0.5);;
}

.tab-content p {
  position: relative;
  top: 300px;
  transition: top 500ms;
}
/* END Colors, graphics and positioning for tabs */
              
            
!

JS

              
                
              
            
!
999px

Console