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

              
                .container.js-fizz-buzz
              
            
!

CSS

              
                :root
  --colour #A56CC1
  --secondaryColour #ACE7EF
  --fontSizeSmall 0.8rem

body
  padding 2rem
  background-color var(--colour)
  font-family karla
  color #fff
  font-size 1.25em

.container
  --size 6rem
  --borderWidth 2px
  display grid
  grid-auto-rows var(--size)
  grid-template-columns repeat(auto-fill, var(--size))
  max-width calc(var(--size) * 8)
  counter-reset fizzBuzz

.container__item
  display flex
  position relative
  padding 1rem
  justify-content center
  align-items center
  counter-increment fizzBuzz
  
  &:before
    position absolute
    top calc(var(--borderWidth) * -0.5)
    right @top
    bottom @top
    left @top
    border-color var(--secondaryColour)
    border-style solid
    border-width var(--borderWidth)
    content ''
  
  &:after
    position absolute
    left 0.5rem
    top @left
    font-size var(--fontSizeSmall)
    line-height 1
    opacity 0.4
    content counter(fizzBuzz)
              
            
!

JS

              
                // The divisor map function is defined here: https://codepen.io/Ash/pen/mVmqqp.
const fizzBuzz = divisorMap({
  3: '🍹',
  5: '🐝',
  // 13: '💩'
})

const container = document.querySelector('.js-fizz-buzz')
const length = 100

for (let i = 1; i <= length; i ++) {
  container.innerHTML += `<div class='container__item'>${fizzBuzz(i)}</div>`
}
              
            
!
999px

Console