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

              
                  <section class="container">
    <button> To toggle between vertical and horizontal tabs, please click here </button>
    <h5> :: If the screen WIDTH is less than 768px the tabs will be transformed to accordion </h5>
      <nav>
          <ul class="clearfix">                    
              <li> <a href="#content1" class="activeTab">  Option 1  </a> </li>
              <li> <a href="#content2">  Option 2  </a> </li>
              <li> <a href="#content3">  Option 3  </a> </li>
          </ul>
      </nav>  
      <section class="navContent">
        <article>
             <input  type="checkbox" name="op1" />
             <span class="smallHide"> <a>Option 1</a> </span>               
             <div class="theContent" id="content1">                     
                 <h1> Oh lovely </h1>
                 <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
                 </p>
            </div>
        </article>
        <article>
            <input  type="checkbox" name="op1" />
            <span class="smallHide"> <a>Option 2</a> </span>                
            <div class="theContent" id="content2">                     
                 <h1> What do you think </h1>
                 <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
                 </p>
            </div>
        </article>
        <article>
            <input  type="checkbox" name="op1" />
            <span class="smallHide"> <a>Option 3</a> </span>                
            <div class="theContent" id="content3">                     
                 <h1> Heading 3 </h1>
                 <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
                 </p>
            </div>
        </article>                               
      </section>      
  </section>  <!-- Container -->  

              
            
!

CSS

              
                $boldHeaderColor: #535353;
$backColor: #dbdbdb;

html {
    font-family: sans-serif;
}

body {
    padding: 10px 30px;
}

/* === General style ===*/
ul {
    margin: 0;
    padding: 0;
    list-style-type: none;
}

p {
    font-size: 15px;
    color: #87878c;
    line-height: 1.5em;
}
h1 {
    margin: 0;
    padding: 0;
}
h5 {
    text-align: center;
    margin: 20px 0;
}

button {
    padding: 20px;
    background: #B2B2B2;
    border: 0 none;
    color: #fff;
    font-size: .8em;
    margin: 15px 30%;
    box-shadow: 0 4px 2px -2px #2b2b2b;
    border-bottom: 3px solid #767171;
    border-radius: 4px;
    cursor: pointer;
    outline: 0;
    font-weight: bold;
    &:hover {
        background: #BEB9B9;
    }
    &:active {
        box-shadow: 0 2px 2px -2px #2b2b2b;
        border-bottom: 1px solid #767171;
    }
}

.smallHide {
    display: none;
}

.activeTab {
    background: #fff;
    box-shadow: inset -6px 0 20px -5px #333;
}

article {
    position: relative;
    margin-top: 1px;
}

/* === Styling the app === */
.container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}
nav {
    ul {
        li {
            float: left;
            width: 31%;
            input[type="radio"] {
                position: absolute;
                cursor: pointer;
                width: 15%;
                height: 1%;
                z-index: 1;
                opacity: 0;
                &:checked ~ a {
                    background: #fff;
                }
            }
            a {
                display: block;
                background: $backColor;
                margin: 0 1px 0 0;
                padding: 20px;
                text-decoration: none;
                color: $boldHeaderColor;
                font-size: 1.1em;
                font-weight: bold;
                &:hover {
                    background: #fff;
                }
            }
        }
    }
}

.navContent {
    .theContent {
        overflow: hidden;
        position: absolute;
        top:10px;
        left:0;
        z-index: 0;
        background: #fff;
        -webkit-transition: all .3s ease;
        transition: all .3s ease;
        min-height: 250px;
    }
    article:first-child div{
      z-index: 1;
    }
    h1 {
        color: $boldHeaderColor;
        font-size: 1.2em;
        margin-top: 1.8em;
    }
}

@media (min-width: 768px) {
    input[type="checkbox"] {
        display: none;
    }
    .navContent {
        .theContent {
            &:target {
              z-index: 1;
            }
        }
    }
}

@media (max-width: 768px) {
    nav {
        display: none;
    }
    .theContent {
        margin-top: 0;
        max-height: 0;
        opacity: 0;
    }
    .smallHide {
        display: block;
        a {
            display: block;
            background: $backColor;
            margin: 0 1px 0 0;
            padding: 20px;
            text-decoration: none;
            color: $boldHeaderColor;
            font-size: 1.1em;
            font-weight: bold;
        }
    }
    input[type="checkbox"] {
        position: absolute;
        cursor: pointer;
        width: 100%;
        height: 100%;
        z-index: 2;
        opacity: 0;
        top: 0;
        left: 0;
        &:checked ~ a {
            background: #fff;
        }
        &:checked ~ .theContent {
            position: relative;
            overflow: hidden;
            max-height: 800px;
            opacity: 1;
            transform: translate(0, 0);
            width: 100%;
            height: 100%;
        }
        &:checked ~ span a {
            background: #fff;
            color: #3c948b;
            box-shadow: 6px 0 8px -5px #333;
        }
    }
}

.clear {
    clear: both;
    display: block;
    overflow: hidden;
    visibility: hidden;
    width: 0;
    height: 0;
}

.clearfix:after {
    clear: both;
    content: ' ';
    display: block;
    font-size: 0;
    line-height: 0;
    visibility: hidden;
    width: 0;
    height: 0;
}

* html .clearfix, *:first-child + html .clearfix {
    zoom: 1;
}

/* ==== Styling the Vertical tab, thiw will be applied just when the container hasing the calss verticalTab ===*/
.verticalTab {
    nav {
        float: left;
        width: 30%;
        ul li {
            float: none;
            width: 100%;
        }
        a {
            margin: 0 0 1px 0;
        }
    }
    .navContent {
        float: left;
        width: 60%;
        margin-left: 1%;
        h1 {
            margin-top: 0;
        }
    }
}


              
            
!

JS

              
                 /** Just a small piece o JS just to gain some time, please read the comments and hope this will be  fine */


/* === Toggle the class just to show the vertical tab, I used this way just to do a "less HTML" 
			What I changed is just the CSS ===*/
    $("button").click(function() {
        $(".container").toggleClass("verticalTab");
    });

    /*** === The trick for the tabs + checkbox with the :target wont work, so I had to use a script just to
    	 change the background color for the active tab === */

    // I used the .find() instead of ("nav ul li a") because the .find is faster in jQuery	 
    $("nav").find("a").click(function() {
        $("nav").find("a").removeClass("activeTab");
        $(this).addClass("activeTab");
    });
              
            
!
999px

Console