Pure CSS / CSS3 Tabbed Content

Category: CSS & CSS3 , Others | June 11, 2015
Author: SoClear
Views Total: 1,461
Official Page: Go to website
Last Update: June 11, 2015
License: MIT

Preview:

Pure CSS / CSS3 Tabbed Content

Description:

A simple, vertical tabbed content widget built using HTML and CSS / CSS3, which is great for backend / admin panels.

How to use it:

Include the Font Awesome for icons.

<link rel="stylesheet" href="font-awesome.min.css">

Create tab navigation using Html radio buttons and labels.

<input type="radio" class="tab-1" name="tab" checked="checked">
<span>Home</span><i class="fa fa-home"></i>

<input type="radio" class="tab-2" name="tab">
<span>Posts</span><i class="fa fa-medium"></i>

<input type="radio" class="tab-3" name="tab">
<span>Users</span><i class="fa fa-user"></i>

<input type="radio" class="tab-4" name="tab">
<span>Comments</span><i class="fa fa-comment"></i>

<input type="radio" class="tab-5" name="tab">
<span>Upload</span><i class="fa fa-cloud-upload"></i>

<input type="radio" class="tab-6" name="tab">
<span>Favorite</span><i class="fa fa-star"></i>

<input type="radio" class="tab-7" name="tab">
<span>Photos</span><i class="fa fa-photo"></i>

<input type="radio" class="tab-8" name="tab">
<span>Analysis</span><i class="fa fa-line-chart"></i>

<input type="radio" class="tab-9" name="tab">
<span>Links</span><i class="fa fa-link"></i>

<input type="radio" class="tab-10" name="tab">
<span>Settings</span><i class="fa fa-cog"></i>

Create tabbed content as follow.

<div class="tab-content">
  <section class="tab-item-1">
    <h1>One</h1>
  </section>
  <section class="tab-item-2">
    <h1>Two</h1>
  </section>
  <section class="tab-item-3">
    <h1>Three</h1>
  </section>
  <section class="tab-item-4">
    <h1>Four</h1>
  </section>
  <section class="tab-item-5">
    <h1>Five</h1>
  </section>
  <section class="tab-item-6">
    <h1>Six</h1>
  </section>
  <section class="tab-item-7">
    <h1>Sever</h1>
  </section>
  <section class="tab-item-8">
    <h1>Eight</h1>
  </section>
  <section class="tab-item-9">
    <h1>Nine</h1>
  </section>
  <section class="tab-item-10">
    <h1>Ten</h1>
  </section>
</div>

The core CSS / CSS3 styles for the tabbed content.

.clear-backend {
  background: #fff;
  width: 100%;
  height: 800px;
  position: relative;
}

.avatar {
  background: #f0f0f0;
  width: 200px;
  height: 200px;
}

.avatar div {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  top: 25px;
  left: 25px;
}

.avatar div img {
  width: 100%;
  height: auto;
}

.clear-backend > input {
  position: absolute;
  filter: alpha(opacity=0);
  opacity: 0;
}

.clear-backend > input:hover {
  cursor: pointer;
}

.clear-backend > input:hover + span,
.clear-backend > input:checked + span {
  background: #fff;
  color: #1ABC9C;
}
.clear-backend > input:checked + span + i {
  color: #1ABC9C;
}

.clear-backend > i {
  position: absolute;
  margin-top: -40px;
  padding: 0 20px;
  font-size: 20px;
}

.clear-backend > span,
.clear-backend > i {
  -webkit-transition: all .5s;
     -moz-transition: all .5s;
     -o-transition: all .5s;
      transition: all .5s;
}

.clear-backend > input,
.clear-backend > span {
  background: #f0f0f0;
  display: block;
  width: 200px;
  height: 60px;
  line-height: 60px;
  text-align: center;
  z-index: 9;
}

.top-bar {
  background: #f0f0f0;
  color: #000;
  position: absolute;
  top: 0;
  right: 0;
  width: calc(100% - 200px);
  height: 60px;
  line-height: 60px;
  font-size: 20px;
  z-index: 9;
}

.top-bar li {
  float: right;
}

.top-bar a {
  display: block;
  padding: 0 20px;
  -webkit-transition: all .5s;
     -moz-transition: all .5s;
     -o-transition: all .5s;
      transition: all .5s;
}

.top-bar a:hover {
  color: #1ABC9C;
}

.top-bar li:hover {
  background: #fff;
}

.tab-content {
  position: absolute;
  top: 0;
  right: 0;
  width: calc(100% - 200px);
  height: 100%;
  padding-top: 60px;
  overflow: hidden;
}

.tab-content section {
  position: absolute;
  width: 100%;
  height: 100%;
  padding: 20px;
  display: none;
}

.clear-backend > input.tab-1:checked ~ .tab-content .tab-item-1 {
  display: block;
}

.clear-backend > input.tab-2:checked ~ .tab-content .tab-item-2 {
  display: block;
}

.clear-backend > input.tab-3:checked ~ .tab-content .tab-item-3 {
  display: block;
}

.clear-backend > input.tab-4:checked ~ .tab-content .tab-item-4 {
  display: block;
}

.clear-backend > input.tab-5:checked ~ .tab-content .tab-item-5 {
  display: block;
}

.clear-backend > input.tab-6:checked ~ .tab-content .tab-item-6 {
  display: block;
}

.clear-backend > input.tab-7:checked ~ .tab-content .tab-item-7 {
  display: block;
}

.clear-backend > input.tab-8:checked ~ .tab-content .tab-item-8 {
  display: block;
}

.clear-backend > input.tab-9:checked ~ .tab-content .tab-item-9 {
  display: block;
}

.clear-backend > input.tab-10:checked ~ .tab-content .tab-item-10 {
  display: block;
}

Make it responsive.

@media only screen and (max-width: 641px) {
  .avatar, 
  .clear-backend > input,
  .clear-backend > span {
    width: 60px;
    height: 60px;
  }
  .clear-backend > span {
    filter: alpha(opacity=0);
    opacity: 0;
  }
  .avatar div {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    top: 5px;
    left: 5px;
  }
  .top-bar,
  .tab-content {
  width: calc(100% - 60px);
  }
}