123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1>Démo onglets</h1>
<!-- Navigation -->
<ul id="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>
            
          
!
            
              @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;
}

            
          
!
            
              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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console