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

              
                mixin cuboid()
  .cuboid(class!=attributes.class)
    - let s = 0
    while s < 6
      .cuboid__side
      - s++

mixin container(amounts)
  .cuboid.cuboid--container
    .cuboid__side(style=`--cols: ${amounts[0][1]}; --rows: ${amounts[0][0]};`)
      - let f = 0
        while f < amounts[0][0] * amounts[0][1]
          .container(style=`--hue: ${Math.random() * 360};`)
          - f++
    .cuboid__side
    .cuboid__side
    .cuboid__side(style=`--cols: ${amounts[1][0]}; --rows: ${amounts[1][1]};`)
      - let b = 0
        while b < amounts[1][0] * amounts[1][1]
          .container(style=`--hue: ${Math.random() * 360};`)
          - b++
    .cuboid__side(style=`--cols: ${amounts[2][1]}; --rows: ${amounts[2][0]};`)
      - let g = 0
      while g < amounts[2][0] * amounts[2][1]
        .container(style=`--hue: ${Math.random() * 360};`)
        - g++
    .cuboid__side
.scene
  .canal
  .boat
    label
      | EVERBEAR
      img(src="https://assets.codepen.io/605876/avatar.png")
    .boat__body
      +cuboid()(class="cuboid--body")
    .boat__container.boat__container--back
      +container([[20, 4], [20, 8], [8, 4]])
    .boat__container.boat__container--middle
      +container([[20, 12], [20, 8], [8, 12]])
    .boat__container.boat__container--front
      +container([[20, 8], [20, 8], [8, 8]])
    .boat__tower.boat__tower--back
      +cuboid()(class="cuboid--tower cuboid--tower-back")
    .boat__tower.boat__tower--front
      +cuboid()(class="cuboid--tower cuboid--tower-front")
  .skiff__container
    .skiff
      .skiff__body
        +cuboid()(class="cuboid--skiff-body")
      .skiff__cabin
        +cuboid()(class="cuboid--skiff-cabin")
      .skiff__hold
        +cuboid()(class="cuboid--skiff-hold")
      .skiff__motor
        +cuboid()(class="cuboid--skiff-motor")




              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Teko:wght@700&display=swap')
.cuboid
  width 100%
  height 100%
  position relative
  // 1 is the top and go t, r, b, l, f, b

  &__side:nth-of-type(1)
    height calc(var(--thickness) * 1vmin)
    width 100%
    position absolute
    top 0
    transform translate(0, -50%) rotateX(90deg)

  &__side:nth-of-type(2)
    height 100%
    width calc(var(--thickness) * 1vmin)
    position absolute
    top 50%
    right 0
    transform translate(50%, -50%) rotateY(90deg)

  &__side:nth-of-type(3)
    width 100%
    height calc(var(--thickness) * 1vmin)
    position absolute
    bottom 0
    transform translate(0%, 50%) rotateX(90deg)

  &__side:nth-of-type(4)
    height 100%
    width calc(var(--thickness) * 1vmin)
    position absolute
    left 0
    top 50%
    transform translate(-50%, -50%) rotateY(90deg)

  &__side:nth-of-type(5)
    height 100%
    width 100%
    transform translate3d(0, 0, calc(var(--thickness) * 0.5vmin))
    position absolute
    top 0
    left 0

  &__side:nth-of-type(6)
    height 100%
    width 100%
    transform translate3d(0, 0, calc(var(--thickness) * -0.5vmin)) rotateY(180deg)
    position absolute
    top 0
    left 0

*
*:after
*:before
  box-sizing border-box
  transform-style preserve-3d

body
  min-height 100vh
  display grid
  place-items center
  background var(--sky)
  overflow hidden
  perspective 100vh

label
  height calc(var(--boat-height) * 0.4)
  font-family 'Teko', sans-serif
  color hsl(0, 0%, 92%)
  letter-spacing 0.1vmin
  transform translate3d(0, 0, calc(var(--boat-depth) * 0.51vmin))
  top 55%
  left 36%
  font-size calc(var(--boat-height) * 0.4)
  display block

  img
    height 65%
    position absolute
    left 100%
    top 50%
    object-fit cover
    filter saturate(0.5)
    transform translate(50%, -50%) rotate(30deg)



.scene
  transform translate3d(-50%, -50%, 0) rotateX(-16deg) rotateY(5deg) rotateX(calc(var(--rotate-x, 0) * 1deg)) rotateY(calc(var(--rotate-y, 0) * 1deg))
  height var(--boat-width)
  width var(--boat-width)
  position fixed
  top 50%
  left 50%

:root
  --base-size 14
  --boat-height calc(var(--base-size) * 0.7vmin)
  --boat-width calc(var(--boat-height) * 4)
  --boat-depth var(--base-size)
  --canal-one hsl(210, 80%, 36%)
  --canal-two hsl(190, 80%, 26%)
  --boat-one hsl(200, 30%, 20%)
  --boat-two hsl(200, 30%, 17%)
  --boat-three hsl(200, 30%, 13%)
  --boat-four hsl(200, 30%, 10%)
  --white-one hsl(0, 0%, 98%)
  --white-two hsl(0, 0%, 94%)
  --white-three hsl(0, 0%, 88%)
  --white-four hsl(0, 0%, 84%)
  --red hsl(10, 80%, 25%)
  --dirt hsl(45, 40%, 60%)
  --sky hsl(210, 80%, 90%)


.skiff__container
  height calc(var(--base-size) * 0.16vmin)
  width calc(var(--base-size) * 0.32vmin)
  // background red
  top calc(50% + (var(--boat-height) * 0.5))
  position absolute
  left 70%
  transform translate3d(-50%, -100%, calc(var(--boat-depth) * 1.5vmin)) rotateY(0deg)
  animation circle 1s infinite linear

  &:after
    content ''
    height calc(var(--boat-depth) * 1.23vmin)
    width calc(var(--boat-depth) * 1.23vmin)
    border-radius 50%
    border calc(var(--base-size) * 0.18vmin) double hsla(180, 80%, 86%, 0.15)
    position absolute
    top 100%
    left 50%
    transform translate(-50%, -50%) rotateX(90deg) translate3d(0, 0, 1px)

@keyframes circle
  to
    transform translate3d(-50%, -100%, calc(var(--boat-depth) * 1.5vmin)) rotateY(360deg)

.skiff
  height 100%
  width 100%
  position relative
  transform translate3d(0, 0, calc(var(--boat-depth) * 0.5vmin))

  &__body
    position absolute
    bottom 0
    left 0
    width 100%
    height 30%

  &__hold
    position absolute
    bottom 30%
    left 10%
    width 40%
    height 20%

  &__cabin
    position absolute
    bottom 30%
    right 16%
    width 40%
    height 60%

  &__motor
    position absolute
    left 0
    height 20%
    width 10%
    bottom 30%

.canal
  height 200vmax
  width calc(var(--boat-width) * 1.12)
  background linear-gradient(90deg, var(--canal-two) 0 5%, var(--canal-one), var(--canal-two) 95% 100%)
  position absolute
  top 50%
  left 50%
  transform translate(-50%, -50%) rotateX(90deg) translate3d(0, 0, calc(var(--boat-height) * -0.5))

  &:after
    content ''
    height 100%
    width 10000%
    background var(--dirt)
    position absolute
    top 50%
    left 50%
    transform translate3d(-50%, -50%, -2px)
    z-index -1


.boat
  --ratio 3.5
  height var(--boat-height)
  width var(--boat-width)
  position absolute
  top 50%
  left 50%
  transform translate(-50%, -50%) rotateY(20deg) rotate(-2deg)

  *
    position absolute

  &__body
    bottom 0
    left 0
    width 100%
    height 45%

  &__container
    bottom 45%
    height 55%

    &--back
      left 1%
      width calc(var(--ratio) * 4%)

    &--middle
      left calc((var(--ratio) * 5%) + 1%)
      width calc(var(--ratio) * 12%)

    &--front
      left calc((var(--ratio) * 18%) + 1%)
      width calc(var(--ratio) * 8%)

  &__tower
    height 70%
    width calc(var(--ratio) * 1%)
    bottom 45%

    &--back
      left calc((var(--ratio) * 4%) + 1%)

    &--front
      height 80%
      left calc((var(--ratio) * 17%) + 1%)

.cuboid--body
  --thickness var(--boat-depth)

  div
    background var(--boat-one)

    &:nth-of-type(2)
      background var(--boat-two)

    &:nth-of-type(4)
      background repeating-linear-gradient(90deg, var(--boat-three) 0 15%, transparent 15% 20%) 50% 10% / 80% 16% no-repeat, var(--boat-two)

      &:after
        content ''
        position absolute
        height 30%
        width 30%
        background linear-gradient(var(--white-four), var(--white-four)) 50% 0 / 100% 35% no-repeat,
                  linear-gradient(var(--white-four), var(--white-four)) 50% 100% / 60% 35% no-repeat
        top 50%
        left 50%
        transform translate(-50%, -50%)


    &:nth-of-type(3)
      background linear-gradient(90deg, var(--red) 0 94%, transparent 94%)

    &:nth-of-type(5)
      background linear-gradient(90deg, var(--boat-four) 0 80%, transparent 80%)
      overflow hidden

      &:after
        content ''
        transform-origin 100% 0
        width 150%
        height 200%
        background var(--boat-four)
        position absolute
        top 0
        right 0
        transform rotate(28deg)

       &:before
        content ''
        height 10%
        width 95%
        left 0
        bottom 0
        position absolute
        background var(--red)
        z-index 2
        transform skewX(-30deg) translate(-1%, 0)

    &:nth-of-type(6)
      background linear-gradient(270deg, var(--boat-four) 0 80%, transparent 80%)
      overflow hidden

      &:after
        content ''
        transform-origin 0 0
        width 150%
        height 200%
        background var(--boat-four)
        position absolute
        top 0
        left 0
        transform rotate(-28deg)

      &:before
        content ''
        height 10%
        width 95%
        right 0
        bottom 0
        position absolute
        background var(--red)
        z-index 2
        transform skewX(30deg) translate(1%, 0)

    &:nth-of-type(2) // Front
      background transparent

      &:after
        content ''
        position absolute
        top 0
        left 0
        width 100%
        height 112%
        background var(--boat-two)
        transform-origin 50% 0
        transform rotateX(-28deg)

.cuboid--container
  --thickness var(--boat-depth)

  div

    &:nth-of-type(1)
    &:nth-of-type(4)
    &:nth-of-type(5)
      display grid
      grid-template-columns repeat(var(--cols), 1fr)
      grid-template-rows repeat(var(--rows), 1fr)
    &:nth-of-type(1)
      --lightness 70
    &:nth-of-type(4)
      --lightness 60
    &:nth-of-type(5)
      --lightness 40

.container
  background 'hsl(%s, 50%, %s)' % (var(--hue, 0) calc(var(--lightness, 50) * 1%))
  position static

.cuboid--tower
  --thickness calc(var(--base-size) * 0.25)

  div
    background var(--white-two)

    &:nth-of-type(1)
      background hsl(0, 0%, 15%)

    &:nth-of-type(5)
      background linear-gradient(hsl(210, 80%, 80%), hsl(210, 80%, 80%)) 50% 8% / 80% 10% no-repeat,
                linear-gradient(hsl(0, 0%, 20%) 0 5%, var(--white-three) 5%)

    &:nth-of-type(4)
      background linear-gradient(hsl(210, 80%, 80%), hsl(210, 80%, 80%)) 50% 8% / 80% 10% no-repeat,
                linear-gradient(hsl(0, 0%, 20%) 0 5%, var(--white-one) 5%)

  &-front
    div
      background var(--white-four)

      &:nth-of-type(1)
        background var(--white-one)

        &:after
          content ''
          position absolute
          height 500%
          width 100%
          background hsla(0, 0%, 100%, 0.4)
          border calc(var(--boat-width) * 0.01) solid var(--white-two)
          top 50%
          left 50%
          transform translate3d(-50%, -50%, calc(var(--boat-height) * -0.15))

      &:nth-of-type(5)
      &:nth-of-type(6)
        &:after
          content ''
          position absolute
          bottom 0
          height 130%
          width 100%
          transform-origin 50% 100%
          transform rotateX(-45deg)
          background hsla(0, 0%, 100%, 0.4)
          border calc(var(--boat-width) * 0.01) solid var(--white-one)

.cuboid--skiff-body
  --thickness calc(var(--base-size) * 0.16)
  div
    background var(--boat-one)

    &:nth-of-type(3)
      background var(--boat-two)
    &:nth-of-type(4)
      background var(--boat-four)
    &:nth-of-type(5)
      background var(--boat-three)

.cuboid--skiff-cabin
  --thickness calc(var(--base-size) * 0.12)
  div
    --base var(--white-two)
    background linear-gradient(hsl(210, 80%, 80%), hsl(210, 80%, 80%)) 50% 12% / 80% 30% no-repeat, var(--base)

    &:nth-of-type(1)
      background var(--boat-three)

    &:nth-of-type(3)
      --base var(--white-two)
    &:nth-of-type(4)
      --base var(--white-four)
    &:nth-of-type(5)
      --base var(--white-three)

.cuboid--skiff-motor
  --thickness calc(var(--base-size) * 0.12)
  div
    background hsl(0, 50%, 40%)

    &:nth-of-type(3)
      background hsl(0, 50%, 50%)
    &:nth-of-type(4)
      background hsl(0, 50%, 60%)
    &:nth-of-type(5)
      background hsl(0, 50%, 70%)

.cuboid--skiff-hold
  --thickness calc(var(--base-size) * 0.12)
  div
    background hsl(0, 0%, 80%)

    &:nth-of-type(3)
      background hsl(0, 0%, 90%)
    &:nth-of-type(4)
      background hsl(0, 0%, 70%)
    &:nth-of-type(5)
      background hsl(0, 0%, 60%)
              
            
!

JS

              
                import gsap from 'https://cdn.skypack.dev/gsap'

const BOUNDS = 10
document.addEventListener('pointermove', ({ x, y }) => {
  const rX = gsap.utils.mapRange(0, window.innerWidth, -BOUNDS, BOUNDS, x)
  const rY = gsap.utils.mapRange(0, window.innerHeight, BOUNDS, -BOUNDS, y)
  gsap.set('.scene', {
    '--rotate-x': rY,
    '--rotate-y': rX,
  })
})

// import { GUI } from 'https://cdn.skypack.dev/dat.gui'

// const CONFIG = {
//   'rotate-x': 0,
//   'rotate-y': 0,
// }

// const BOUNDS = {
//   'rotate-x': [-360, 360, 1],
//   'rotate-y': [-360, 360, 1],
// }

// const CONTROLLER = new GUI()

// const UPDATE = () => {
//   for (const KEY of Object.keys(CONFIG)) {
//     document.documentElement.style.setProperty(`--${KEY}`, CONFIG[KEY])
//   }
// }

// const digest = (CONFIG_OBJECT, BOUNDS_OBJECT, FOLDER) => {
//   for (const category in BOUNDS_OBJECT) {
//     if (Array.isArray(BOUNDS_OBJECT[category])) {
//       FOLDER.add(
//         CONFIG_OBJECT,
//         category,
//         BOUNDS_OBJECT[category][0],
//         BOUNDS_OBJECT[category][1],
//         BOUNDS_OBJECT[category][2] ? BOUNDS_OBJECT[category][2] : 1
//       ).onChange(UPDATE)
//     } else {
//       const NEW_FOLDER = FOLDER
//         ? FOLDER.addFolder(category)
//         : GUI.addFolder(category)
//       digest(CONFIG_OBJECT[category], BOUNDS_OBJECT[category], NEW_FOLDER)
//     }
//   }
// }
// digest(CONFIG, BOUNDS, CONTROLLER)

              
            
!
999px

Console