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

              
                svg(xmlns='http://www.w3.org/2000/svg' viewBox='0 0 25.981 30')
  defs
    g#cube.cube
      path(d='M8.66 12.5v5l4.33 2.5v-5z')
      path(d='M12.99 15v5l4.33-2.5v-5z')
      path(d='M8.66 12.5l4.33-2.5 4.33 2.5-4.33 2.5z')
  - for (let c = 0; c < 27; c++)
    - const layer = Math.floor(c / 9)
    - const row = c % 3
    - const position = (Math.floor(c / 3)) % 3
    g.cube__holder(data-layer=layer data-row=row data-position=position data-index=c)
      use(href="#cube")
              
            
!

CSS

              
                *
  box-sizing border-box

:root
  --bg hsl(0, 0%, 6%)
  --hue-one 47
  --hue-two 167
  --hue-three 287

body
  min-height 100vh
  display flex
  align-items center
  justify-content center
  background var(--bg)

svg
  width 25vmin
  overflow visible !important

.cube
  path
    stroke-width 0.1
    stroke var(--panel)
    fill var(--panel)
    &:nth-of-type(1)
      --color 'hsl(%s, 100%, 65%)' % var(--hue-one)
      --panel var(--color)
    &:nth-of-type(2)
      --color 'hsl(%s, 100%, 65%)' % var(--hue-two)
      --panel var(--color)
    &:nth-of-type(3)
      --color 'hsl(%s, 100%, 65%)' % var(--hue-three)
      --panel var(--color)
              
            
!

JS

              
                const {
  gsap: { set, timeline },
} = window
const RESET = () => {
  set('[data-layer="0"]', {
    yPercent: 50,
  })
  set('[data-layer="1"]', {
    yPercent: 0,
  })
  set('[data-layer="2"]', {
    yPercent: -50,
  })
  set('[data-row="0"', {
    xPercent: -50,
    yPercent: '-=25',
  })
  set('[data-row="1"', {
    xPercent: 0,
  })
  set('[data-row="2"', {
    xPercent: 50,
    yPercent: '+=25',
  })
  set('[data-position="0"', {
    xPercent: '+=50',
    yPercent: '-=25',
  })
  set('[data-position="2"', {
    xPercent: '-=50',
    yPercent: '+=25',
  })
}

RESET()

let hueOne
let hueTwo
let hueThree

set(['.cube', '.cube__holder'], { transformOrigin: '50% 50%', scale: 1.01 })

timeline({
  repeat: -1,
  repeatDelay: 0.5,
  onRepeat: () => {
    document.documentElement.style.setProperty('--hue-one', hueOne)
    document.documentElement.style.setProperty('--hue-two', hueTwo)
    document.documentElement.style.setProperty('--hue-three', hueThree)
  },
})
  .to('[data-row="0"]', {
    xPercent: '-=50',
    yPercent: '-=25',
  })
  .to(
    '[data-row="2"]',
    {
      yPercent: '+=25',
      xPercent: '+=50',
    },
    '<'
  )
  .to('[data-position="0"]', {
    xPercent: '+=50',
    yPercent: '-=25',
  })
  .to(
    '[data-position="2"]',
    {
      xPercent: '-=50',
      yPercent: '+=25',
    },
    '<'
  )
  .to('[data-layer="0"]', {
    yPercent: '+=50',
  })
  .to(
    '[data-layer="2"]',
    {
      yPercent: '-=50',
    },
    '<'
  )
  .to('[data-layer="1"][data-row="1"][data-position="1"]', {
    onStart: () => {
      hueOne = Math.random() * 359
      hueTwo = Math.random() * 359
      hueThree = Math.random() * 359
      set('[data-layer="1"][data-row="1"][data-position="1"]', {
        '--hue-one': hueOne,
        '--hue-two': hueTwo,
        '--hue-three': hueThree,
      })
    },
    duration: 0.2,
    scale: 3,
  })
  .to(
    [
      '[data-layer="2"][data-row="0"][data-position="0"]',
      '[data-layer="1"][data-row="0"][data-position="0"]',
      '[data-layer="0"][data-row="0"][data-position="0"]',
    ],
    {
      duration: 0.5,
      xPercent: '0',
      yPercent: '-=400',
      opacity: 0,
    },
    '>-0.1'
  )
  .to(
    [
      '[data-layer="2"][data-row="1"][data-position="0"]',
      '[data-layer="1"][data-row="1"][data-position="0"]',
      '[data-layer="0"][data-row="1"][data-position="0"]',
    ],
    {
      duration: 0.5,
      xPercent: '+=400',
      yPercent: '-=200',
      opacity: 0,
    },
    '<'
  )
  .to(
    [
      '[data-layer="2"][data-row="2"][data-position="0"]',
      '[data-layer="1"][data-row="2"][data-position="0"]',
      '[data-layer="0"][data-row="2"][data-position="0"]',
    ],
    {
      duration: 0.5,
      xPercent: '+=600',
      opacity: 0,
    },
    '<'
  )
  .to(
    [
      '[data-layer="2"][data-row="0"][data-position="1"]',
      '[data-layer="1"][data-row="0"][data-position="1"]',
      '[data-layer="0"][data-row="0"][data-position="1"]',
    ],
    {
      duration: 0.5,
      xPercent: '-=400',
      yPercent: '-=200',
      opacity: 0,
    },
    '<'
  )
  .to(
    [
      '[data-layer="2"][data-row="0"][data-position="2"]',
      '[data-layer="1"][data-row="0"][data-position="2"]',
      '[data-layer="0"][data-row="0"][data-position="2"]',
    ],
    {
      duration: 0.5,
      xPercent: '-=600',
      opacity: 0,
    },
    '<'
  )
  .to(
    [
      '[data-layer="2"][data-row="2"][data-position="1"]',
      '[data-layer="1"][data-row="2"][data-position="1"]',
      '[data-layer="0"][data-row="2"][data-position="1"]',
    ],
    {
      duration: 0.5,
      xPercent: '+=400',
      yPercent: '+=200',
      opacity: 0,
    },
    '<'
  )
  .to(
    [
      '[data-layer="2"][data-row="2"][data-position="2"]',
      '[data-layer="1"][data-row="2"][data-position="2"]',
      '[data-layer="0"][data-row="2"][data-position="2"]',
    ],
    {
      duration: 0.5,
      yPercent: '+=600',
      opacity: 0,
    },
    '<'
  )
  .to(
    [
      '[data-layer="2"][data-row="1"][data-position="2"]',
      '[data-layer="1"][data-row="1"][data-position="2"]',
      '[data-layer="0"][data-row="1"][data-position="2"]',
    ],
    {
      duration: 0.5,
      xPercent: '-=400',
      yPercent: '+=200',
      opacity: 0,
    },
    '<'
  )
  .to(
    '[data-layer="0"][data-row="1"][data-position="1"]',
    {
      yPercent: '+=600',
      opacity: 0,
      duration: 0.5,
    },
    '<'
  )
  .to(
    '[data-layer="2"][data-row="1"][data-position="1"]',
    {
      yPercent: '-=600',
      opacity: 0,
      duration: 0.5,
    },
    '<'
  )

              
            
!
999px

Console