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

              
                <h1 class="title">Simple JavaScript Tab Bar</h1>
<div class="container">
  <ul class="container__list">
    <li class="container__item container__item_active">
      <span class="container__link">Intro</span>
    </li>
    <li class="container__item">
      <span class="container__link">HTML</span>
    </li>
    <li class="container__item">
      <span class="container__link">CSS</span>
    </li>
    <li class="container__item">
      <span class="container__link">JavaScript</span>
    </li>
    <li class="container__item">
      <span class="container__link">Animation</span>
    </li>
  </ul>
  <div class="container__inner">
    <h2 class="content__subtitle">Intro</h2>
    <p class="content__description">
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit, illum ipsam nesciunt nisi perferendis quisquam repellendus reprehenderit voluptatum? A cupiditate, deleniti doloremque hic iste praesentium quia quidem quisquam sunt vel.
    </p>
  </div>
  <div class="container__inner container__inner_hidden">
    <h2 class="content__subtitle">HTML</h2>
    <p class="content__description">
      The HyperText Markup Language, or HTML(HyperText Markup Language) is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScript.
    </p>
  </div>
  <div class="container__inner container__inner_hidden">
    <h2 class="content__subtitle">CSS</h2>
    <p class="content__description">
      Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML. CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.
    </p>
  </div>
  <div class="container__inner container__inner_hidden">
    <h2 class="content__subtitle">JavaScript</h2>
    <p class="content__description">
      JavaScript, often abbreviated as JS, is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled and multi-paradigm. It has dynamic typing, prototype-based object-orientation and first-class functions.
    </p>
  </div>
  <div class="container__inner container__inner_hidden">
    <h2 class="content__subtitle">Animation</h2>
    <p class="content__description">
      CSS animations make it possible to animate transitions from one CSS style configuration to another. Animations consist of two components, a style describing the CSS animation and a set of keyframes that indicate the start and end states of the animation’s style, as well as possible intermediate waypoints.
    </p>
  </div>
</div>
              
            
!

CSS

              
                html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: "Ubuntu", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: radial-gradient(
    circle,
    rgba(239, 241, 173, 1) 3%,
    rgba(160, 195, 237, 1) 100%
  );
}

.title {
  margin: 30px 0;
  padding: 0;
  color: #4c6067;
  font-size: 36px;
  line-height: 36px;
  letter-spacing: 1px;
  font-weight: 700;
  text-rendering: optimizeLegibility;
}

.container {
  width: 100%;
  min-height: 270px;
  max-width: 800px;
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-sizing: border-box;
  box-shadow: rgba(33, 35, 38, 0.1) 0 10px 10px -10px;
}

.container__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-rows: repeat(1, minmax(min-content, max-content));
  grid-template-columns: repeat(5, minmax(min-content, max-content));
  grid-auto-rows: minmax(min-content, max-content);
  grid-auto-columns: minmax(min-content, max-content);
  justify-content: space-around;
  gap: 10px 20px;
}

.container__item {
  width: 100px;
  color: #4c6067;
  min-height: 30px;
  border-radius: 3px;
  display: grid;
  justify-content: center;
  align-content: center;
  cursor: pointer;
  position: relative;
  font-size: 16px;
  line-height: 16px;
  letter-spacing: 1px;
  font-weight: 400;
  transition: 0.2s;
}

.container__item::after {
  content: "";
  display: block;
  position: absolute;
  width: 40%;
  margin: 0 30%;
  bottom: 0;
  border-bottom: 1px solid #4c6067;
}

.container__item_active {
  background: #4c6067;
  box-sizing: border-box;
  color: #ebfaff;
  font-weight: 300;
}

.container__link {
  margin: 0;
  padding: 0;
}

.container__inner {
  width: 80%;
  margin: 45px auto 35px;
}

.content__subtitle {
  animation-name: smoothTop;
  animation-duration: 0.3s;
  font-size: 22px;
  line-height: 22px;
  font-weight: 500;
  color: #404648;
}

.content__description {
  animation-name: smoothBottom;
  animation-duration: 0.7s;
  font-size: 14px;
  line-height: 22px;
  font-weight: 300;
  color: #404648;
}

.container__inner_hidden {
  display: none;
}

@keyframes smoothTop {
  0% {
    opacity: 0.2;
    transform: translateY(7%);
  }
  100% {
    opacity: 1;
    transform: translateY(0%);
  }
}

@keyframes smoothBottom {
  0% {
    opacity: 0.2;
    transform: translateY(-3%);
  }
  100% {
    opacity: 1;
    transform: translateY(0%);
  }
}

              
            
!

JS

              
                let tabContent = document.querySelectorAll(".container__inner");
let tabItem = document.querySelectorAll(".container__item");

// For each element with class 'container__item'
for (let i = 0; i < tabItem.length; i++) {
  // if the element was hovered
  //you can replace mouseover with click
  tabItem[i].addEventListener("mouseover", () => {
    // Add to all containers class 'container__inner_hidden'
    tabContent.forEach((item) => {
      item.classList.add("container__inner_hidden");
    });
    // Clean all links from class 'container__item_active'
    tabItem.forEach((item) => {
      item.classList.remove("container__item_active");
    });
    // Make visible correct tab content and add class to item
    tabContent[i].classList.remove("container__inner_hidden");
    tabItem[i].classList.add("container__item_active");
  });
}

              
            
!
999px

Console