Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              - let columns = 15
- let rows = 20
- let cells = columns * rows
  svg.replay__icon(viewBox="0 0 24 24")
    path(d="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z")
.bear-grid(style=`--cells: ${cells}; --columns: ${columns}; --rows: ${rows}`)
  - for(let b = 1; b < cells + 1; b++)
    .bear-grid__cell(style=`--x: ${(b - 1) % columns}; --y: ${b % columns === 0 ? Math.floor(b / columns) - 1 : Math.floor(b / columns)}; --destinationY: ${Math.floor(Math.random() * 500)}; --destinationX: ${Math.floor(Math.random() * 500)}; --rotation: ${Math.floor(Math.random() * 360)}`)

  box-sizing border-box
  animation  fadeIn .5s

  background-color #111
  display flex
  align-items center
  justify-content center
  min-height 100vh

  --height 320
  --width 240
  display grid
  grid-template-rows repeat(var(--rows), 1fr)
  grid-template-columns repeat(var(--columns), 1fr)
  height calc(var(--height) * 1px)
  transition height .25s, width .25s
  width calc(var(--width) * 1px)

  @media(min-width 768px)
    --height 400
    --width 300

  &--fading .bear-grid__cell
    animation-play-state running
    animation-name driftAway

    --cellWidth calc((calc(var(--width) * -1px)) / var(--columns))
    --cellHeight calc((calc(var(--height) * -1px)) / var(--rows))
    background url(
    background-size calc(var(--width) * 1px) calc(var(--height) * 1px)
    background-position calc(var(--x) * var(--cellWidth)) calc(var(--y) * var(--cellHeight))
    animation-delay calc(var(--x) * .2s + 1s)
    animation-fill-mode backwards
    animation-duration 4s
    animation-play-state paused
    opacity 0
    transform translate(calc(var(--destinationX) * -1px), calc(var(--destinationY) * -1px)) rotate(calc(var(--rotation) * 1deg)) scale(0)

  animation fadeIn .25s
  background 0
  border 0
  cursor pointer
  display none
  height 44px
  left 50%
  margin-left -22px
  margin-top -22px
  padding 0
  position fixed
  top 50%
  width 44px
  z-index 2

    transform translateY(5%)

    display block

    height 44px
    width 44px

      fill #fff

@keyframes fadeIn
    opacity 0

@keyframes driftAway
    transform translate(0, 0) rotate(0deg) scale(1)
    opacity 1
              const bearGrid = document.querySelector('.bear-grid')
const bearCells = bearGrid.querySelectorAll('.bear-grid__cell')
const lastCell = bearCells[bearCells.length - 1]
const replay = document.querySelector('.replay')

const imageHasLoaded = (src) => new Promise((resolve, reject) => {
  const img = new Image()
  img.onload = resolve
  img.onerror = reject
  img.src = src

const showReset = () => {

const fade = () => {

lastCell.addEventListener('animationend', showReset)
replay.addEventListener('click', fade)

  .then(() => {
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.