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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                ul.nav
  li
    a(href='/link1.html') Another page
  li
    a(href='/cpe/boomboom/index.html') Current page
  li
    a(href='/link3.html') Another page
  li
    a(href='/link4.html') Another page
br
p En raison de son appel à window.location, le script a du mal à se lancer dans l'iframe du CodePen, mais dans des conditions normales il est pleinement opérationnel. Le cas échéant, ouvrir la console du Pen pour relancer le script.

              
            
!

CSS

              
                .nav
  display flex
  flex-wrap no-wrap
  gap 0 1em
  margin 0
  padding 0
  & li
    display block
    & a
      display block
      padding 1em
      text-decoration none
      color #fff
      background-color #c94e38
      &:focus
      &:hover
      &:active
        background-color darkOrange

.nav li.current
  position relative
  & a
    background-color darkOrange
  &::after
    content ''
    position absolute
    top 100%
    left calc(50% - 1em)
    width 2em
    height 1em
    background-color darkOrange
    clip-path polygon(0 0, 100% 0, 50% 100%)

body
  margin 0
  font-family Arial
  line-height 1.5
  font-size 1em
  color #fff
  background-color #333

p
  max-width 40em
              
            
!

JS

              
                'use strict'

const currentTabNavigation = (() => {
  document.querySelectorAll('.nav a').forEach(el => {
    if (location.pathname === el.pathname) el.parentElement.classList.add('current')
  })
})()

              
            
!
999px

Console