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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                
<input id="tilt" type="checkbox"/>
<div class="scene">
  <div class="plane">
    <div class="xbox__shadow"></div>
    <div class="xbox__plane">
      <div class="cuboid xbox">
        <div class="cuboid__side">
          <div class="cuboid xbox__leg">
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
          </div>
          <div class="cuboid xbox__leg">
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
          </div>
          <div class="cuboid xbox__leg">
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
          </div>
          <div class="cuboid xbox__leg">
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
          </div>
          <label class="tilter" for="tilt" title="Toggle orientation"></label>
        </div>
        <div class="cuboid__side"></div>
        <div class="cuboid__side"><svg class="xbox__logo" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
  <title>Xbox icon</title>
  <path d="M4.102 21.033C6.211 22.881 8.977 24 12 24c3.026 0 5.789-1.119 7.902-2.967 1.877-1.912-4.316-8.709-7.902-11.417-3.582 2.708-9.779 9.505-7.898 11.417zm11.16-14.406c2.5 2.961 7.484 10.313 6.076 12.912C23.002 17.48 24 14.861 24 12.004c0-3.34-1.365-6.362-3.57-8.536 0 0-.027-.022-.082-.042-.063-.022-.152-.045-.281-.045-.592 0-1.985.434-4.805 3.246zM3.654 3.426c-.057.02-.082.041-.086.042C1.365 5.642 0 8.664 0 12.004c0 2.854.998 5.473 2.661 7.533-1.401-2.605 3.579-9.951 6.08-12.91-2.82-2.813-4.216-3.245-4.806-3.245-.131 0-.223.021-.281.046v-.002zM12 3.551S9.055 1.828 6.755 1.746c-.903-.033-1.454.295-1.521.339C7.379.646 9.659 0 11.984 0H12c2.334 0 4.605.646 6.766 2.085-.068-.046-.615-.372-1.52-.339C14.946 1.828 12 3.545 12 3.545v.006z"/>
</svg>
          <div class="xbox__face">
            <div class="xbox__eye xbox__eye--left"></div>
            <div class="xbox__eye xbox__eye--right"></div>
            <div class="xbox__mouth"></div>
            <div class="xbox__sleep xbox__sleep--one">Z</div>
            <div class="xbox__sleep xbox__sleep--two">Z</div>
            <div class="xbox__sleep xbox__sleep--three">Z</div>
          </div>
          <button class="xbox__power" title="Power on/off"></button>
        </div>
        <div class="cuboid__side"></div>
        <div class="cuboid__side"><svg class="xbox__logo" role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
  <title>Xbox icon</title>
  <path d="M4.102 21.033C6.211 22.881 8.977 24 12 24c3.026 0 5.789-1.119 7.902-2.967 1.877-1.912-4.316-8.709-7.902-11.417-3.582 2.708-9.779 9.505-7.898 11.417zm11.16-14.406c2.5 2.961 7.484 10.313 6.076 12.912C23.002 17.48 24 14.861 24 12.004c0-3.34-1.365-6.362-3.57-8.536 0 0-.027-.022-.082-.042-.063-.022-.152-.045-.281-.045-.592 0-1.985.434-4.805 3.246zM3.654 3.426c-.057.02-.082.041-.086.042C1.365 5.642 0 8.664 0 12.004c0 2.854.998 5.473 2.661 7.533-1.401-2.605 3.579-9.951 6.08-12.91-2.82-2.813-4.216-3.245-4.806-3.245-.131 0-.223.021-.281.046v-.002zM12 3.551S9.055 1.828 6.755 1.746c-.903-.033-1.454.295-1.521.339C7.379.646 9.659 0 11.984 0H12c2.334 0 4.605.646 6.766 2.085-.068-.046-.615-.372-1.52-.339C14.946 1.828 12 3.545 12 3.545v.006z"/>
</svg><span class="xbox__label">XBOX</span>
          <label class="tilter tilter--vertical" for="tilt" title="Toggle orientation"></label>
        </div>
        <div class="cuboid__side">
          <div class="cuboid xbox__leg">
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
          </div>
          <div class="cuboid xbox__leg">
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
          </div>
          <div class="cuboid xbox__leg">
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
          </div>
          <div class="cuboid xbox__leg">
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
            <div class="cuboid__side"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                *
  box-sizing border-box

:root
  --perspective 1200
  --rotate-x -15
  --rotate-y -40
  --xbox-scale 4
  --xbox-width calc(5.9 * var(--xbox-scale))
  --xbox-height calc(2.5 * var(--xbox-scale))
  --xbox-depth calc(10.8 * var(--xbox-scale))
  --plane-width var(--xbox-width)
  --plane-height var(--xbox-depth)
  --transition .1s
  --power 0

body
  min-height 100vh
  // overflow hidden
  background hsl(158, 40%, 41%)

.scene
  perspective calc(var(--perspective, 800) * 1px)
  transform-style preserve-3d
  height 100vh
  width 100vw
  display flex
  align-items center
  justify-content center

.plane
  height calc(var(--plane-height, 25) * 1vmin)
  width calc(var(--plane-width, 25) * 1vmin)
  transform-style preserve-3d
  transform rotateX(calc(var(--rotate-x, -24) * 1deg)) rotateY(calc(var(--rotate-y, -24) * 1deg)) rotateX(90deg) translate3d(0, 0, calc((var(--xbox-height) * -0.5) * 1vmin))


// This is what makes the CSS variable powered cuboid
.cuboid
  --width var(--cuboid-width, 15)
  --height var(--cuboid-height, 10)
  --depth var(--cuboid-depth, 4)
  height calc(var(--depth) * 1vmin)
  width calc(var(--width) * 1vmin)
  position absolute
  transform translate3d(calc(var(--x, 0) * 1vmin), calc(var(--y, 0) * 1vmin), calc(var(--z, 0) * 1vmin)) rotateX(calc(var(--rotate-cuboid-x, 0) * 1deg)) rotateY(calc(var(--rotate-cuboid-y, 0) * 1deg)) rotateZ(calc(var(--rotate-cuboid-z, 0) * 1deg))
  transform-style preserve-3d

  &__side
    transform-style preserve-3d

  & > div:nth-of-type(1)
    height calc(var(--height) * 1vmin)
    width 100%
    transform-origin 50% 50%
    transform rotateX(-90deg)
    position absolute
    top 50%
    left 50%
    transform translate(-50%, -50%) rotateX(-90deg) translate3d(0, 0, calc((var(--depth) / 2) * 1vmin))

  & > div:nth-of-type(2)
    height calc(var(--height) * 1vmin)
    width 100%
    transform-origin 50% 50%
    transform translate(-50%, -50%) rotateX(-90deg) rotateY(180deg) translate3d(0, 0, calc((var(--depth) / 2) * 1vmin))
    position absolute
    top 50%
    left 50%

  & > div:nth-of-type(3)
    height calc(var(--height) * 1vmin)
    width calc(var(--depth) * 1vmin)
    transform translate(-50%, -50%) rotateX(-90deg) rotateY(90deg) translate3d(0, 0, calc((var(--width) / 2) * 1vmin))
    position absolute
    top 50%
    left 50%

  & > div:nth-of-type(4)
    height calc(var(--height) * 1vmin)
    width calc(var(--depth) * 1vmin)
    transform translate(-50%, -50%) rotateX(-90deg) rotateY(-90deg) translate3d(0, 0, calc((var(--width) / 2) * 1vmin))
    position absolute
    top 50%
    left 50%

  & > div:nth-of-type(5)
    height calc(var(--depth) * 1vmin)
    width calc(var(--width) * 1vmin)
    transform translate(-50%, -50%) translate3d(0, 0, calc((var(--height) / 2) * 1vmin))
    position absolute
    top 50%
    left 50%

  & > div:nth-of-type(6)
    height calc(var(--depth) * 1vmin)
    width calc(var(--width) * 1vmin)
    transform translate(-50%, -50%) translate3d(0, 0, calc((var(--height) / 2) * -1vmin)) rotateX(180deg)
    position absolute
    top 50%
    left 50%

// ...while the Series S is 60 percent
// smaller at 27.5cm (10.8 inches) x 15.1cm
// (5.9 inches) x  63.5cm (2.5 inches).
.xbox
  --width var(--xbox-width)
  --height var(--xbox-height)
  --depth var(--xbox-depth)
  --z calc(var(--xbox-height) * 0.5)

  &.xbox--on
    .xbox__sleep
      display none
    .xbox__mouth
      animation wake-up-mouth 5s
    .xbox__eye
      animation wake-up 5s, eye-blink 5s 5s infinite

    & > div:nth-of-type(3) .xbox__logo
      animation-name blink
      animation-iteration-count 8
      animation-duration 1s
      animation-fill-mode both
      animation-timing-function steps(2, start)

      @keyframes blink
        to
          fill white

  &__face
    height 20%
    width 20%
    left 50%
    top 50%
    position absolute
    transform translate3d(-50%, -50%, 1px)
    transform-style preserve-3d

  &__mouth
    height 2.5vmin
    width 2.5vmin
    border-radius 50%
    background black
    position absolute
    bottom 0
    left 50%
    margin-left -1.25vmin
    -webkit-clip-path inset(50% 0 0 0)
    clip-path inset(50% 0 0 0)
    overflow hidden
    transform-origin 50% 75%
    transform translate(0, 25%) scale(calc(0.1 + (var(--power) * 0.9)))

    &:after
      content ''
      position absolute
      bottom 0
      right 0
      height 50%
      width 50%
      background red
      border-radius 50%
      transform translate(0, 50%)

  &__sleep
    font-weight bold
    font-family sans-serif
    font-size 3rem
    position absolute
    left 100%
    opacity 0.75
    bottom 100%
    color hsl(158, 40%, 20%)
    transform-origin 0% 100%
    transform scale(0) translate3d(0, 0, 0)
    animation sleep calc(var(--s, 1) * 1s) calc(var(--d, 0) * 1s) infinite both

    &--one
      --x 200
      --y -300
      --d 0.2
      --s 1
    &--two
      --x 150
      --y -200
      --d 0.4
      --s 2
    &--three
      --x 250
      --y -150
      --d 0.6
      --s 1.8

  &__eye
    height 1.75vmin
    width 1.75vmin
    background black
    position absolute
    top 0
    border-radius 50%
    transform scaleY(calc(0.1 + (var(--power) * 0.9)))

    @keyframes eye-blink
      0%, 49%, 51%, 100%
        transform scaleY(1)
      50%
        transform scaleY(0.1)

    &--left
      left 0
    &--right
      right 0

    &:after
      content ''
      position absolute
      top 25%
      left 25%
      height 20%
      width 20%
      background white
      border-radius 50%


  & > div
    // Front facing end
    &:nth-of-type(1)
    &:nth-of-type(2)
      background hsl(0, 0%, 80%)

      &:after
        content ""
        position absolute
        background repeating-radial-gradient(hsl(0, 0%, 60%) 0 50%, transparent 50% 100%) 0 0 / 6px 6px, hsl(0, 0%, 80%)
        width 90%
        height 90%
        left 5%
        top 5%
    // Front panel
    &:nth-of-type(3)
      background hsl(0, 0%, 85%)

      &:after
        content ''
        background hsl(0, 0%, 10%)
        height 10%
        width 5%
        position absolute
        bottom 15%
        left 4%
      &:before
        content ''
        background hsl(0, 0%, 10%)
        height 0.5vmin
        width 0.5vmin
        border-radius 50%
        bottom 15%
        left 11%
        position absolute

    // Back panel
    &:nth-of-type(4)
      background hsl(0, 0%, 95%)

      &:after
        content ''
        height 15%
        bottom 15%
        right 5%
        position absolute
        background repeating-linear-gradient(90deg, hsl(0, 0%, 50%) 0 90%, transparent 90% 100%) 0 0 / 20% 100%, transparent
        width 55%

      &:before
        content ''
        height 20%
        bottom 35%
        right 7%
        position absolute
        width 15%
        background repeating-radial-gradient(hsl(0, 0%, 50%) 0 50%, transparent 50% 100%) 0 0 / 0.5vmin 0.5vmin, transparent


    // Top panel
    &:nth-of-type(5)
      background hsl(0, 0%, 90%)

      &:after
        content ''
        background repeating-radial-gradient(hsl(0, 0%, 0%) 0 50%, transparent 50% 100%) 0 0 / 0.75vmin 0.75vmin, hsl(0, 0%, 15%)
        position absolute
        border-radius 50%
        left 50%
        top calc(var(--xbox-width) * 0.1vmin)
        transform translate(-50%, 0)
        width calc(var(--xbox-width) * 0.9vmin)
        height calc(var(--xbox-width) * 0.9vmin)

    // Bottom panel
    &:nth-of-type(6)
      background hsl(0, 0%, 75%)

      &:after
        content ""
        position absolute
        background repeating-radial-gradient(hsl(0, 0%, 35%) 0 50%, transparent 50% 100%) 0 0 / 0.5vmin 0.5vmin, hsl(0, 0%, 75%)
        width 90%
        height 15%
        left 5%
        top 5%

  & > div:nth-of-type(5) .xbox__logo
    position absolute
    bottom 5%
    left 5%
    height 4%
    transform rotate(-90deg)
    fill hsl(0, 0%, 55%)

  &__label
    font-family sans-serif
    bottom 9%
    left 8.5%
    font-size 0.5rem
    position absolute
    transform-origin 0 50%
    transform rotate(-90deg)
    color hsl(0, 0%, 55%)

  & > div:nth-of-type(3) .xbox__logo
    height 100%
    position absolute
    right 5%
    top 10%
    height 20%

  &__shadow
    height 100%
    width 100%
    background radial-gradient(circle at 50% 50%, hsla(0, 0%, 0%, 0.5), transparent)
    filter blur(5px)
    position absolute
    transition transform var(--transition), background var(--transition), filter var(--transition)

  &__plane
    height 100%
    width 100%
    transform-style preserve-3d
    transform translate3d(0, 0, 0.5vmin)
    transform-origin 50% 100%
    transition transform var(--transition)

  &__power
    height 100%
    width 100%
    position absolute
    z-index 2
    border 0
    cursor pointer
    opacity 0

  &__leg
    --width 1
    --depth 0.5
    --height 0.25

    transform translate3d(0, 0vmin, calc(var(--height) * 0.5vmin))

    &:nth-of-type(1)
      top 5%
      left 5%
    &:nth-of-type(2)
      top 5%
      right 5%
    &:nth-of-type(3)
      bottom 5%
      left 5%
    &:nth-of-type(4)
      bottom 5%
      right 5%
    & > div
      &:nth-of-type(1)
        background hsl(0, 0%, 80%)
      &:nth-of-type(2)
        background hsl(0, 0%, 83%)
      &:nth-of-type(3)
        background hsl(0, 0%, 88%)
      &:nth-of-type(4)
        background hsl(0, 0%, 85%)
      &:nth-of-type(5)
        background hsl(0, 0%, 85%)
      &:nth-of-type(6)
        background hsl(0, 0%, 75%)

label
  position absolute
  height 100%
  width 100%
  transform translate3d(0, 0, 1px)
  cursor pointer
  opacity 0

.tilter--vertical
  display none

[type="checkbox"]
  height 0
  width 0
  opacity 0
  position fixed
  left 100%

:checked ~ .scene
  .xbox__plane
    transform rotateX(-90deg)
  .tilter--vertical
    display block
  .xbox__shadow
    transform-origin 50% 100%
    transform scaleY(1.5)
    background radial-gradient(circle at 50% 100%, hsla(0, 0%, 0%, 0.5), transparent 75%)
    filter blur(15px)

  .xbox__mouth
    --start-scale 0.45
    --scale 0.45
    -webkit-clip-path inset(0 0 0 0)
    clip-path inset(0 0 0 0)
    transform translate(0, 25%) scale(0.45)

    &:after
      opacity 0

@keyframes wake-up
  0%, 57%, 75%, 77%, 83%
    transform scaleY(0.1)
  50%, 56%, 58%, 74%, 76%, 78%, 82%, 84%
    transform scaleY(1)

@keyframes wake-up-mouth
  0%
    transform translate(0, 25%) scale(var(--start-scale, 0.1))
  50%, 100%
    transform translate(0, 25%) scale(var(--scale, 1))


@keyframes sleep
  to
    transform scale(1) translate3d(calc(var(--x, 100) * 1%), calc(var(--y, -250) * 1%), 0)
              
            
!

JS

              
                const STARTUP = new Audio(
  'https://assets.codepen.io/605876/xbox-series-startup.mp3'
)

const XBOX = document.querySelector('.xbox')
const POWER = document.querySelector('.xbox__power')
let POWERED = false
POWER.addEventListener('click', () => {
  POWERED = !POWERED
  if (POWERED) {
    STARTUP.play()
  } else {
    STARTUP.pause()
    STARTUP.currentTime = 0
  }
  document.documentElement.style.setProperty('--power', POWERED ? 1 : 0)
  XBOX.classList.toggle('xbox--on')
})

              
            
!
999px

Console