Pen Settings

HTML

CSS

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

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.

Details

Privacy

Go PRO Window blinds lowered to protect code. Code Editor with window blinds (raised) and a light blub turned on.

Keep it secret; keep it safe.

Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.

Upgrade to PRO

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.

Template

Make Template?

Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.

Template URL

Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:

Screenshot

Screenshot or Custom Thumbnail

Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.

This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.

Upgrade to PRO

HTML

              
                <div class="container active">
  <div class="text"><p>First line one<br/>First line two</p></div>
  <div class="text text1"><p>First line one<br/>First line two</p></div>
  <div class="text text2"><p>First line one<br/>First line two</p></div>
  <div class="text text3"><p>First line one<br/>First line two</p></div>
</div>

<div class="container hidden">
  <div class="text text4"><p>Second line one<br/>Second line two</p></div>
  <div class="text text5"><p>Second line one<br/>Second line two</p></div>
  <div class="text text6"><p>Second line one<br/>Second line two</p></div>
  <div class="text text7"><p>Second line one<br/>Second line two</p></div>
</div>
  
<div class="container hidden">
  <div class="text text8"><p>Third line one<br/>Third line two</p></div>
  <div class="text text9"><p>Third line one<br/>Third line two</p></div>
  <div class="text text10"><p>Third line one<br/>Third line two</p></div>
  <div class="text text11"><p>Third line one<br/>Third line two</p></div>
</div>

<button id="next">Next</button>
              
            
!

CSS

              
                .container {
  display: flex;
  width: 100%;
  justify-content: space-around;
  font-size: 18px;
}

.line {
  display: none;
}

.active {
  display: flex;
}

button {
  margin-top: 2rem;
  font-size: 18px;
  box-shadow: 1px 1px 5px #909090;
  padding: 0.25rem 1rem;
  cursor: pointer;
}

button:hover {
  background: #fcfcfc;
  border: 2px solid #fcfcfc;
}
              
            
!

JS

              
                // TweenMax are the animations

// Wrap each line of text in all .text containers in a separate div and give it a class of .line
const text = new SplitText(document.querySelectorAll(".text"), { type: "lines", linesClass: "line" });

const elements = document.querySelectorAll(".container")

// Hide all elements with .line class if their container is not active
for (const element of elements) {
  if (!element.classList.contains('active')) {
    TweenMax.to(element.querySelectorAll(".line"), 0, { y: 30, autoAlpha: 0 })
  }
}

document.getElementById("next").addEventListener("click", function () {
  let activeIndex = 0
  let index = 0

// Loop through containers and check if .active
  for (const element of elements) {
    if (element.classList.contains('active')) {
      activeIndex = index
    }
    index ++
  }

  // Fade out lines in container which currently has .active and set to .hidden
  elements[activeIndex].classList.remove('active')
  elements[activeIndex].classList.add('hidden')
  
  let hiddenLines = [elements[activeIndex].querySelectorAll(".line")]
  
  for (const hLine of hiddenLines) {
      TweenMax.staggerTo(hLine, 0.5, { y: -30, autoAlpha: 0 }, 0.1)
  }
  
  // Increment element index
  let nextIndex = activeIndex + 1
  if (nextIndex >= elements.length) {nextIndex = 0}

  // Fade in next lines and set .active to container
  elements[nextIndex].classList.remove('hidden')
  elements[nextIndex].classList.add('active')
  TweenMax.staggerTo(elements[nextIndex].querySelectorAll(".line"), 0.5, { y: 0, autoAlpha: 1 }, 0.1)
})
              
            
!
999px
Save your sass for CSS. Everywhere else be kind.

Console