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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <h1>Démo onglets</h1>
<!-- Navigation -->
<ul class="tab-nav">
  <li><a href="#" data-tab="onglet1" class="tab-nav-active">Onglet 1</a></li>
  <li><a href="#" data-tab="onglet2">Onglet 2</a></li>
  <li><a href="#" data-tab="onglet3">Onglet 3</a></li>
</ul>

<!-- Contenu des onglets -->
<div id="onglet1" class="tab tab-active">
  <img src="https://picsum.photos/300/200" class="img-right">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam libero tellus, tincidunt non velit egestas, facilisis venenatis velit. Sed nec mi tristique, ornare nunc eget, euismod ligula. Etiam vitae lacus mattis, euismod purus eu, euismod eros. Curabitur
    et nunc bibendum, sollicitudin leo ut, auctor dolor. Ut semper lobortis ex, in porttitor nibh pretium pharetra. Sed elit est, vestibulum sed porttitor ac, hendrerit vel ipsum. Sed in felis ipsum. Fusce interdum sapien et urna auctor, tincidunt placerat
    augue bibendum. Fusce at ipsum ut magna lacinia vestibulum. Pellentesque condimentum tempor sem et ullamcorper. Nulla a tortor tortor. Sed ac libero commodo, imperdiet quam id, pharetra urna. Vestibulum quis metus turpis. Nunc eget pulvinar ex, quis
    varius erat. </p>

</div>
<div id="onglet2" class="tab">
  <img src="https://picsum.photos/200/200" class="img-left">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam libero tellus, tincidunt non velit egestas, facilisis venenatis velit. Sed nec mi tristique, ornare nunc eget, euismod ligula. Etiam vitae lacus mattis, euismod purus eu, euismod eros. Curabitur
    et nunc bibendum, sollicitudin leo ut, auctor dolor. Ut semper lobortis ex, in porttitor nibh pretium pharetra. Sed elit est, vestibulum sed porttitor ac, hendrerit vel ipsum. Sed in felis ipsum. Fusce interdum sapien et urna auctor, tincidunt placerat
    augue bibendum. Fusce at ipsum ut magna lacinia vestibulum. Pellentesque condimentum tempor sem et ullamcorper. Nulla a tortor tortor. Sed ac libero commodo, imperdiet quam id, pharetra urna. Vestibulum quis metus turpis. Nunc eget pulvinar ex, quis
    varius erat. </p>

</div>
<div id="onglet3" class="tab">
  <img src="https://picsum.photos/400/200" class="img-center">
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=PT+Sans");

$color: #fbaf31;

body {
  font-family: "PT Sans", sans-serif;
  background-color: #efefef;
}

/* Navigation */
.tab-nav {
  /* Suppression des marges internes et externes */
  margin: 0px;
  padding: 0px;
  /* Décalage pour masquer la bordure du contenu */
  position: relative;
  bottom: -1px;
}
.tab-nav li {
  /* Affichage des éléments du menu côte à côte */
  display: inline-block;
}
/* Aspect des onglets inactifs (par défaut) */
.tab-nav a {
  display: block;
  border: 1px solid #cccccc;
  border-width: 1px 1px 0 1px;
  padding: 10px 15px;
  border-radius: 5px 5px 0 0;
  background-color: $color;
  text-decoration: none;
  color: #fff;
  transition-duration: 0.5s;
}
/* Effet de survol sur les onglets */
.tab-nav a:hover {
  background-color: darken($color, 15%);
}
/* Aspect des onglets actifs */
.tab-nav .tab-nav-active {
  background-color: #ffffff;
}
.tab-nav a.tab-nav-active {
  color: $color;
}
.tab-nav a.tab-nav-active:hover {
  background-color: #fff;
}

/* Contenu des onglets */
.tab {
  /* Masquage des onglets*/
  display: none;
  border: 1px solid #cccccc;

  padding: 15px;
  min-height: 250px;
  background-color: #fff;
}
/* Affichage du contenu actif */
.tab-active {
  display: block;
}

img {
  border: 1px solid #ccc;
  padding: 8px;
  -webkit-box-shadow: 5px 5px 8px 2px #656565;
  box-shadow: 5px 5px 8px 2px #656565;
}
.img-right {
  float: right;
  margin-left: 15px;
}
.img-left {
  float: left;
  margin-right: 15px;
}
.img-center {
  display: block;
  margin: auto;
}

              
            
!

JS

              
                jQuery(document).ready(function() {
  /* On surveille les cliques sur les liens du menu */
  jQuery(".tab-nav a").click(function(e) {
    /* On désactive l'action par défaut des liens */
    e.preventDefault();

    /* On récupère la valeur de l'onglet à activer */
    var tab = jQuery(this).data("tab");

    /* On masque tous les contenus */
    jQuery(".tab").removeClass("tab-active");

    /* On affiche le contenu qui doit l'être */
    jQuery("#" + tab).addClass("tab-active");

    /* On désactive tous les onglets */
    jQuery(".tab-nav a").removeClass("tab-nav-active");

    /* On active l'onglet qui a été cliqué */
    jQuery(this).addClass("tab-nav-active");
  });
});

              
            
!
999px

Console