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

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

              
                <div class="tabs">
  <div class="tabs-container">
    <button class="tab active-tab">Accueil</button>
    <button class="tab">Services</button>
    <button class="tab">A propos</button>
    </div>
  
  <div class="tab-content active-tab-content">
    <h2>Accueil</h2>
    <p>
      Lorem ipsum dolor sit amet. Qui dolores harum ab itaque voluptatem non dolor quidem. Est tenetur beatae 33 omnis enim et quidem dolore.
    </p>
  </div>
  
  <div class="tab-content">
    <h2>Services</h2>
    <p>
      Lorem ipsum dolor sit amet. Vel praesentium veniam non earum magnam et ratione dignissimos est illum natus. Et officia quos et tenetur optio ea velit itaque non dolor dolorum non internos aperiam quo nostrum ipsa est asperiores tempore. Non maiores assumenda vel iure provident aut animi dolor et perspiciatis soluta est autem mollitia. Et sunt incidunt qui adipisci velit in nihil veritatis id error quae sed architecto doloremque et aliquam incidunt.
    </p>
  </div>
  
  <div class="tab-content">
    <h2>A propos</h2>
    <p>
      Lorem ipsum dolor sit amet. Vel praesentium veniam non earum magnam et ratione dignissimos est illum natus. Et officia quos et tenetur optio ea velit itaque non dolor dolorum non internos aperiam quo nostrum ipsa est asperiores tempore. Non maiores assumenda vel iure provident aut animi dolor et perspiciatis soluta est autem mollitia. Et sunt incidunt qui adipisci velit in nihil veritatis id error quae sed architecto doloremque et aliquam incidunt.
    </p>
    
    <p>Qui quia quibusdam id ipsum vero ut maiores tenetur. Qui reiciendis mollitia aut magni quod non necessitatibus tenetur quo nihil dolorum aut doloribus animi. Eum labore laboriosam aut voluptatem similique quo reprehenderit perspiciatis aut quia nemo sed libero error.
</p>
  </div>
  
</div>
              
            
!

CSS

              
                *, ::before, ::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: sans-serif;
  background: #111;
}

.tabs {
  background: #070707;
  max-width: 800px;
  margin: 100px auto 0;
  border-radius: 10px;
  border: 1px solid #ffffff3e;
  color: #bbb;
  display: grid;
  grid-template-rows: min-content 1fr;
}

.tabs-container {
  display: flex;
  border-bottom: 1px solid #ffffff3e;
}

.tab {
  border: none;
  background: transparent;
  color: #bbb;
  font-family: sans-serif;
  flex-basis: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  font-weight: bold;
  padding: 30px 0;
  cursor: pointer;
}

.tab:not(:nth-child(3)) {
  border-right: 1px solid #ffffffe3;
}

.tab:nth-child(1) {
  border-top-left-radius: 9px;
}

.tab:nth-child(3) {
  border-top-right-radius: 9px;
}

.tab-content {
  padding: 40px;
  grid-row-start: 2;
  grid-column-start: 1;
  min-height: 200px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s;
}

.tab-content p {
  margin-top: 20px;
  line-height: 1.6;
}

.tab-content h2 {
  font-size: 25px;
}

.active-tab {
  background: linear-gradient(45deg, rgb(139, 59, 210),rgb(47, 30, 152));
  color: white;
}

.active-tab-content {
  visibility: visible;
  opacity: 1;
}
              
            
!

JS

              
                const tabs = Array.from(document.querySelectorAll(".tab"));

tabs.forEach(tab => {
  tab.addEventListener("click", tabsAnimation);
});

function tabsAnimation(e) {
  const tabContents = Array.from(document.querySelectorAll(".tab-content"));
  const indexToRemove = tabs.findIndex(tab => tab.classList.contains("active-tab"));
  const indexToShow = tabs.indexOf(e.target);
  
  // Toggle les classes sur les onglets
  tabs[indexToRemove].classList.remove("active-tab");
  tabs[indexToShow].classList.add("active-tab");
  
  // Toggle les classes sur les contenues
  tabContents[indexToRemove].classList.remove("active-tab-content");
  tabContents[indexToShow].classList.add("active-tab-content");
}
              
            
!
999px

Console