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

              
                <ul id="abas" class="teste">
  <li class="selecionada"><a id="aba_1" href="#aba_1">Aba 1</a></li>
  <li><a id="aba_2" href="#aba_2">Aba 2</a></li>
  <li><a id="aba_3" href="#aba_3">Aba 3</a></li>
</ul>
<div id="conteudos">
  <div id="conteudo_1" class="conteudo visivel">
    <p>Conteúdo da Aba 1</p>
  </div>
  <div id="conteudo_2" class="conteudo">
    <p>Conteúdo da Aba 2</p>
  </div>
  <div id="conteudo_3" class="conteudo">
    <p>Conteúdo da Aba 3</p>
  </div>
</div>
              
            
!

CSS

              
                body{
  font-family: Verdana, Arial, calibri;
  font-size: 16px;
  color: #666666;
}
#abas{
  margin:0;
  padding:0;
}
#abas li{
  display:inline-block;
  border: 1px solid #CCCCCC;
  border-bottom:none;
  background-color:#EEEEEE;
}
#abas li a{
  padding: 10px 20px;
  display: block;
  text-decoration:none;
  color:#000000;
}
#abas li.selecionada{
  background-color:#FFFFFF;
  position:relative;
  top:1px;
  font-weight:bold;
}
#abas li.selecionada a{
  padding-top: 11px
}
.conteudo{
  display:block;
  padding:10px;
  border: 1px solid #CCCCCC;
  display:none;
}
.conteudo.visivel{
  display:block;
}
              
            
!

JS

              
                var abas = document.getElementById("abas");
var conteudos = document.getElementById("conteudos");

/* Essa função retira a classe "selecionada" e esconde a DIV com o conteúdo visível */
function limparSelecao(){
  abas.getElementsByClassName("selecionada")[0].classList.remove("selecionada");
  conteudos.getElementsByClassName("visivel")[0].classList.remove("visivel");
}

/* Essa é executada quando alguma das abas é clicada */
abas.addEventListener("click", function(event){
  var abaClicada = event.target.id;
  var itemSelecionado = abaClicada.substring(abaClicada.lastIndexOf("_"));

  /* Chama função que tira a seleção do item atual */
  limparSelecao();

  /* Insere a classe "selecionada" na nova aba visível */
  event.target.parentElement.classList.add("selecionada");

  /* Insere a classe "visivel" para o conteúdo da aba selecionada */
  conteudos.querySelector("#conteudo"+ itemSelecionado).classList.add("visivel");
});
              
            
!
999px

Console