CSS Tabs

by kshep92

HTML

<div class="tabs">
    
   <div class="tab">
       <input type="radio" id="tab-1" name="tab-group-1" checked>
       <label for="tab-1">Tab One</label>
       
       <div class="content">
           stuff
       </div> 
   </div>
    
   <div class="tab">
       <input type="radio" id="tab-2" name="tab-group-1">
       <label for="tab-2">Tab Two</label>
       
       <div class="content">
           More stuff <br />
           More stuff <br />
           More stuff <br />
           More stuff <br />
           More stuff <br />
           More stuff <br />
       </div> 
   </div>
    
    <div class="tab">
       <input type="radio" id="tab-3" name="tab-group-1">
       <label for="tab-3">Tab Three</label>
     
       <div class="content">
           Even more stuff
       </div> 
   </div>
    
</div>

CSS

.tabs { 
  clear: both;
  margin: 25px 0;
  position: relative;
}

.tab {
  float: left;
  margin-left: -1px;
}

.tab label {
  background: #eee; 
  padding: 10px; 
  border: 1px solid #ccc;
  position: relative;
  top: 1px;
  z-index: 2;
}

.content {
    padding: 20px;
    position: absolute;
    top: 28px;
    left: -1px;
    border: 1px solid #ccc; 
    display: none;
    width: 80%;
    z-index: 1;
}

.tab [type=radio] {
  display: none;   
}


[type=radio]:checked ~ label {
  background: white;
  border-bottom: 1px solid white;
}

[type=radio]:checked ~ label ~ .content {
  display: block;
}