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

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

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

input(type="radio" name="fan" id="zero")
input(type="radio" name="fan" id="one" checked="true")
input(type="radio" name="fan" id="two")
input(type="radio" name="fan" id="three")

.scene
  .fan
    .fan__base
      +cuboid()(class="base")
    .fan__controls
      label.fan__control(for="zero")
        +cuboid()(class="control")
      label.fan__control(for="one")
        +cuboid()(class="control")
      label.fan__control(for="two")
        +cuboid()(class="control")
      label.fan__control(for="three")
        +cuboid()(class="control")
    .fan__spine
      +cuboid()(class="spine")
    .fan__head
      .fan__rotater
        +cuboid()(class="rotater")
        .fan__stalk
          +cuboid()(class="stalk")
      //- Use this as the ring
      .fan__barrel
        +cuboid()(class="barrel")
      .fan__housing
        .fan__housing-rear
        .fan__blades
          .fan__blade
          .fan__blade
          .fan__blade
        .fan__housing-front
          img(src="https://assets.codepen.io/605876/avatar.png")

              
            
!

CSS

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

:root
  --blade-speed 1
  --rotation 25
  --fan-speed 2
  --state running
  --bg hsl(210, 32%, 30%)
  --shade-one hsl(0, 0%, 95%)
  --shade-two hsl(0, 0%, 90%)
  --shade-three hsl(0, 0%, 85%)
  --shade-four hsl(0, 0%, 80%)
  --shade-five hsl(0, 0%, 75%)
  --shade-six hsl(0, 0%, 70%)
  --shade-seven hsl(0, 0%, 65%)
  --shade-eight hsl(0, 0%, 60%)
  --cage-one hsla(210, 80%, 100%, 0.4)
  --cage-two hsla(210, 80%, 100%, 0.2)

body
  min-height 100vh
  display grid
  place-items center
  background var(--bg)
  overflow hidden
  transform scale(0.75)

img
  height 20%
  position absolute
  top 50%
  left 50%
  transform translate3d(-50%, -50%, 1px)
  filter grayscale(1)
  opacity 0.5

input[type="radio"]
  position fixed
  top 0
  left 100%
  opacity 0

#zero:checked ~ .scene
  --blade-speed 0
  --state paused

  .fan__stalk
    transform translate(-50%, 25%)

#one:checked ~ .scene
  --blade-speed 1
  --state running

  .fan__control:nth-of-type(2)
    transition transform 0.1s cubic-bezier(0, 1.4, .2, 1.4)
    transform translate(0, 50%)

#two:checked ~ .scene
  --blade-speed 0.5
  --state running

  .fan__control:nth-of-type(3)
    transition transform 0.1s cubic-bezier(0, 1.4, .2, 1.4)
    transform translate(0, 50%)

#three:checked ~ .scene
  --blade-speed 0.25
  --state running

  .fan__control:nth-of-type(4)
    transition transform 0.1s cubic-bezier(0, 1.4, .2, 1.4)
    transform translate(0, 50%)

.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

:root
  --height 70vmin
  --width 40vmin

label
  transition transform 0.1s
  cursor pointer

label:hover
  transform translate(0, 20%)

label:active
  transform translate(0, 40%)

.scene
  position absolute
  height var(--width)
  width var(--width)
  top 50%
  left 50%
  transform translate3d(-50%, -50%, 0vmin) rotateX(-24deg) rotateY(34deg) rotateX(90deg)

.fan
  height var(--height)
  width var(--width)
  position absolute
  top 50%
  left 50%
  transform translate(-50%, -50%) rotateX(-90deg) rotateX(calc(var(--rotateX, 0) * 1deg)) rotateY(calc(var(--rotateY, 0) * 1deg))

  &__base
    position absolute
    bottom 0
    left 50%
    transform translate(-50%, 0)
    height 8%
    width 80%

  &__controls
    height 6%
    width 50%
    position absolute
    bottom 6%
    left 50%
    transform translate3d(-50%, 0, calc(var(--width) * 0.3))
    display grid
    grid-template-columns repeat(4, 1fr)
    grid-gap 6%

  &__housing
    height 150%
    width 150%
    border-radius 50%
    top 50%
    left 50%
    position absolute
    border 1vmin solid var(--shade-one)
    background var(--cage-one)
    transform translate3d(-50%, -50%, calc(var(--width) * 0.45))

  &__housing-rear
  &__housing-front
    position absolute
    top 50%
    left 50%
    height 80%
    width 80%
    background var(--cage-two)
    border-radius 50%
    border 1vmin solid var(--shade-one)

  &__housing-front
    transform translate3d(-50%, -50%, calc(var(--width) * 0.11))

    &:after
      content ''
      position absolute
      top 50%
      left 50%
      height 35%
      width 35%
      transform translate(-50%, -50%)
      border-radius 50%
      background var(--shade-one)

  &__housing-rear
    transform translate3d(-50%, -50%, calc(var(--width) * -0.1))
    border 1vmin solid var(--shade-two)

  &__head
    height var(--width)
    width var(--width)
    position absolute
    top 0
    left 0
    transform translate3d(0, 0, calc(var(--width) * -0.25))
    animation fan calc(var(--fan-speed, 1) * 1s) infinite alternate ease-in-out var(--state)

  &__rotater
    top 50%
    width calc(var(--width) * 0.2)
    height calc(var(--width) * 0.2)
    position absolute
    left 50%
    transform translate(-50%, -50%)

  &__spine
    height 57.5%
    bottom 8%
    width 20%
    position absolute
    left 50%
    transform translate3d(-50%, 0%, calc(var(--width) * -0.25))

  &__stalk
    height 150%
    left 50%
    bottom 0
    transform translate(-50%, 0)
    transition transform 0.2s cubic-bezier(0, 1.4, .2, 1.4)
    width 25%
    position absolute

  &__blades
    position absolute
    top 50%
    left 50%
    height 16%
    width 16%
    transform translate3d(-50%, -50%, -1px) rotate(0deg)
    animation rotate calc(var(--blade-speed, 0) * 1s) infinite linear

  &__blade
    height 300%
    width 100%
    background var(--shade-one)
    position absolute
    top 50%
    left 50%
    transform-origin 50% 0
    transform translate(-50%, 0) rotate(calc(var(--rotate, 0) * 1deg))

    &:nth-of-type(1)
      --rotate 0
    &:nth-of-type(2)
      --rotate calc(360 / 3 * 1)
    &:nth-of-type(3)
      --rotate calc(360 / 3 * 2)

  &__barrel
    height 22.5%
    width 22.5%
    position absolute
    top 50%
    left 50%
    transform translate3d(-50%, -50%, calc(var(--width) * 0.3))

.base
  --thickness calc(40 * 0.8)

  div
    background var(--shade-two)

    &:nth-of-type(1)
      background var(--shade-one)
    &:nth-of-type(5)
      background var(--shade-three)
    &:nth-of-type(4)
      background va(--shade-six)

.control
  --thickness calc(((40 * 0.5) - ((40 * 0.5) * 0.18)) / 3)

  div
    background var(--shade-five)

    &:nth-of-type(1)
      background var(--shade-three)
    &:nth-of-type(5)
      background var(--shade-six)
    &:nth-of-type(4)
      background va(--shade-eight)

.fan__control:nth-of-type(1) .control
  --shade-three hsl(25, 80%, 85%)
  --shade-five hsl(25, 80%, 75%)
  --shade-six hsl(25, 80%, 70%)
  --shade-eight hsl(25, 80%, 60%)


.spine
  --thickness calc(40 * 0.2)

  div
    background var(--shade-three)

    &:nth-of-type(1)
      background var(--shade-two)
    &:nth-of-type(5)
      background var(--shade-four)
    &:nth-of-type(4)
      background va(--shade-seven)

.rotater
  --thickness calc(40 * 0.2)

  div
    background var(--shade-two)

    &:nth-of-type(1)
      background var(--shade-one)
    &:nth-of-type(5)
      background var(--shade-three)
    &:nth-of-type(4)
      background va(--shade-six)

.barrel
  --thickness calc(40 * 0.5)

  div
    background var(--shade-three)

    &:nth-of-type(1)
      background var(--shade-two)
    &:nth-of-type(5)
      background var(--shade-four)
    &:nth-of-type(4)
      background va(--shade-seven)

.stalk
  --thickness calc(40 * 0.05)

  div
    background var(--shade-four)

    &:nth-of-type(1)
      background var(--shade-three)
    &:nth-of-type(5)
      background var(--shade-five)
    &:nth-of-type(4)
      background va(--shade-eight)

@keyframes fan
  0%, 5%
    transform translate3d(0, 0, calc(var(--width) * -0.25)) rotateY(calc(var(--rotation, 0) * 1deg))
  95%, 100%
    transform translate3d(0, 0, calc(var(--width) * -0.25)) rotateY(calc(var(--rotation, 0) * -1deg))

@keyframes rotate
  from
    transform translate3d(-50%, -50%, -1px) rotate(0deg)
  to
    transform translate3d(-50%, -50%, -1px) rotate(360deg)
              
            
!

JS

              
                
              
            
!
999px

Console