cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <ul class="tab">
  <li><a href="">onglet 1</a></li>
  <li><a href="">onglet 2</a></li>
  <li><a href="">onglet 3</a></li>
</ul>
<div class="content">
  <p>Contenu 1 : Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vero quasi, eius sequi molestias. Quod facilis eaque ut eum, quas ratione, corporis natus quibusdam. Necessitatibus perferendis, amet quidem suscipit, eos voluptatum.</p>
</div>
<div class="content">
  <p>Contenu 2 : Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam repellat veritatis harum reiciendis eos natus quo vero alias quae delectus praesentium, voluptate exercitationem ut nobis nulla quibusdam, et labore quia!</p>
</div>
<div class="content">
  <p>Contenu 3 : Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod, fugiat. Aliquam adipisci inventore officia, doloribus placeat accusantium velit, cumque nemo distinctio aspernatur quam possimus aliquid sint molestias, ipsum esse quia!</p>
</div>
            
          
!
            
              p{
  margin: 10px;
}
.tab{
  overflow: hidden;
  background-color: rgb(100,100,100);
  margin: 5px;
}
.tab a{
  text-decoration: none;
  display: block;
  float: left;
  padding: 10px;
  transition : all 0.5s ease;
  color: white;
}
.tab .active{
  background-color: rgb(200,200,200);
  color: #000;
}
.content{
  display: none;
  animation : fade 1s;
}

@keyframes fade {
  0% {opacity: 0;}
  100% {opacity: 1;}
}
            
          
!
            
              (function(){
  function $(selecteur){
    return document.querySelectorAll(selecteur);
  }
  var onglets = $('.tab a');
  var contenus = $('.content'); 
  function reset(obj,i){
    obj.style.display = "none";
    onglets[i].classList.remove("active");
  }
  function tab(evt){
    contenus.forEach(reset);
    evt.preventDefault(); // annule l'action du lien'
    this.classList.add("active");
    contenus[this.rang].style.display = "block";
  }
  var init = function(obj,i){
    obj.rang = i ;
    obj.addEventListener('click',tab);
  }

  onglets[0].classList.add("active");
  contenus[0].style.display = "block";
  onglets.forEach(init);
}).call(this);
            
          
!
999px
Loading ..................

Console