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

              
                .aquarium
  .seaweed.seaweed--one
  .seaweed.seaweed--two
  .seaweed.seaweed--three
  .fish.animated
    .segment.segment-1
      .segment.segment-2
        .segment.segment-3
          .segment.segment-4
            .segment.segment-5
              .segment.segment-6
                .segment.segment-7
                  .segment.segment-8
                    .segment.segment-9
                      .segment.segment-10
                        .segment.segment-11
                          .segment.segment-12
                            .segment.segment-13
                              .segment.segment-14
                                .segment.segment-15
                                  .segment.segment-16
                                    .segment.segment-17
                                      .segment.segment-18
                                        .segment.segment-19
                                          .segment.segment-20
                                            .segment.segment-21
                                              .segment.segment-22
                                                .segment.segment-23
                                                  .segment.segment-24
                                                    .segment.segment-25
                                                      .segment.segment-26

//- - var n = 0
//- .aquarium
//-   .fish
//-     while n < 26
//-       - n++
//-       .segment(class='segment-' + n)

              
            
!

CSS

              
                // includes modifiers mixin
// includes colors mixin
$color-settings: (
  'colors': (
    'a': ( 0: #222 ),
    'b': ( 0: darkorange ),
    'c': ( 0: gold ),
    'd': ( 0: forestgreen ),
  )
);
@include define-color-set;

$size: 12px;

$fish-colors: (
  0: color(transparent),
  1: color(b),
  2: color(b, 1),
  3: color(b, 2),
  4: color(b, 3),
  5: color(b, 4),
  6: color(c),
  7: color(c, 1),
  8: color(a),
  9: color(white),
);

@function buildSegment($color-list) {
  $shadow: 0 0 0 0 transparent;
  $x: 0;
  @each $color in $color-list {
    $x: $x + 1;
    $shadow: $shadow, 0 (($size * $x) * -1) 0 0 map-get($fish-colors, $color);
  }
  @return $shadow;
}

$seaweed-colors: (
  0: color(transparent),
  1: color(d, -1),
  2: rgba(color(d, -1), .4),
  8: color(d, 1),
  9: color(white),
);

@mixin buildSeaweed($color-list) {
  $shadow: 0 0 0 0 transparent;
  @for $i from 1 through length($color-list) {
    $x: 0;
    @each $color in map-get($color-list, $i) {
      $x: $x + 1;
      $shadow: $shadow, ($size * $i) (($size * $x) * -1) 0 0 map-get($seaweed-colors, $color);
    }
  }
  box-shadow: $shadow;
}


body {
  background: linear-gradient(20deg, royalblue, deepskyblue, mix(darkturquoise, deepskyblue, 70%));
  overflow: hidden;
  perspective: $size * 100;
  position: relative;
  
  &:after {
    border-radius: 50%;
    box-shadow: (
      0 0 20vh 20vh rgba(black, .2),
      20vw -5vh 20vh 20vh rgba(black, .2),
      40vw 3vh 20vh 20vh rgba(black, .2),
      60vw -2vh 20vh 20vh rgba(black, .2),
      80vw 5vh 20vh 20vh rgba(black, .2),
      100vw 0 20vh 20vh rgba(black, .2),
    );
    content: '';
    height: 2px;
    left: 0%;
    position: absolute;
    top: 100%;
    width: 2px;
  }
}
.fish {
  // opacity: 0;
  align-items: flex-end;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-center;
  height: $size * 21;
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  transform-style: preserve-3d;
  width: $size * 26;
  z-index: 10;
  
  &.animated {
    display: block;
    margin-left: $size * 26;
    margin-top: $size * 21;
    
    .segment {
      animation: swim 1.6s ease-in-out infinite alternate;
      display: inline-block;
      left: -$size;
      margin-left: 1px;
      position: relative;
      transform: {
        origin: right;
        style: preserve-3d;
      }
      
      @for $i from 1 through 7 {
        &-#{$i} {
          animation: none;
        }
      }
      
      @for $i from 8 through 26 {
        &-#{$i} {
          animation: {
            delay: #{$i * .1}s;
          }
        }
      }
    }
    
    @keyframes swim {
      from {
        transform: rotateY(-4deg);
      }
      to {
        transform: rotateY(4deg);
      }
    }
  }
}

.segment {
  height: $size;
  width: $size;
  
  $segment-colors: (
    26: (0 0 0 0 0 0 8 8 8 8 8 8 8),
    25: (0 0 0 0 0 8 3 3 3 3 3 3 3 8),
    24: (0 0 0 0 0 0 8 2 1 1 1 2 8),
    23: (0 0 0 0 0 0 0 8 9 9 9 8),
    22: (0 0 0 0 0 0 0 8 9 9 9 8),
    21: (0 0 0 0 0 0 8 1 1 1 2 2 8),
    20: (0 0 0 0 0 0 8 1 1 2 2 2 3 8),
    19: (0 0 0 0 0 8 7 1 8 8 8 2 2 3 8),
    18: (0 0 0 0 0 8 9 8 5 5 8 9 9 9 8),
    17: (0 0 0 0 8 9 8 5 1 1 2 8 9 9 9 8),
    16: (0 0 0 0 8 9 8 5 1 2 2 8 9 9 9 8),
    15: (0 0 0 0 8 7 8 1 1 1 2 8 3 3 9 4 8 8),
    14: (0 0 0 8 7 7 8 1 1 2 2 8 3 3 3 4 3 5 8),
    13: (8 8 8 4 7 7 7 1 1 1 2 2 2 3 3 4 3 3 5 8),
    12: (8 5 1 4 7 7 1 1 1 2 2 2 3 3 3 4 1 1 3 8),
    11: (8 5 1 4 7 9 9 9 9 9 9 9 2 3 3 4 3 3 5 8),
    10: (8 5 1 4 9 9 9 9 9 9 9 9 9 9 3 4 1 1 3 8),
     9: (0 8 8 4 9 9 9 9 9 9 9 9 9 9 9 4 3 5 5 8),
     8: (0 0 0 8 9 7 1 1 1 2 2 2 9 9 9 4 8 8 8),
     7: (0 0 0 8 7 7 7 1 1 1 2 2 2 3 9 8),
     6: (0 0 0 0 8 7 1 1 1 6 6 2 3 3 8),
     5: (0 0 0 0 8 7 7 1 1 8 8 2 2 8),
     4: (0 0 0 0 8 7 4 6 6 1 2 2 2 8),
     3: (0 0 0 0 0 8 4 8 6 1 2 2 8),
     2: (0 0 0 0 0 8 4 4 6 1 8 8),
     1: (0 0 0 0 0 0 8 8 8 8),
  );
  
  $i: 0;
  @each $segment in $segment-colors {
    $i: $i + 1;
    &.segment-#{$i} {
      box-shadow: buildSegment(map-get($segment-colors, $i));
    }
  }
}

.seaweed {
  $animation-front: unique-id();
  $animation-back: unique-id();
  
  bottom: -$size;
  height: $size;
  left: 50%;
  position: absolute;
  transform: translateX(100vw);
  width: $size;

  &--one,
  &--three {
    $seaweed-map: (
      1: (0 0 1 1 1 2 2 2 2 0 0 0 0 0 0 0 0 0 1 1 1 0 2 2 2),
      2: (0 0 1 1 1 1 2 2 2 2 0 0 0 0 0 0 0 0 1 1 1 1 1 2 2 2),
      3: (2 1 1 1 8 8 8 1 2 2 2 1 1 0 0 2 2 1 1 1 8 8 8 1 2 0 0 1 1),
      4: (1 1 1 8 1 1 2 8 8 1 1 1 1 1 1 2 1 1 1 8 1 1 2 8 1 1 1 1 1 1),
      5: (8 8 8 1 1 2 2 2 1 8 8 8 1 1 1 1 8 8 8 1 1 2 2 2 8 8 8 8 1 1 8 1),
      6: (1 1 1 1 1 2 2 2 1 1 1 1 8 8 8 8 1 1 1 1 1 2 2 2 1 1 1 1 8 8 1),
      7: (2 1 1 1 0 2 2 2 0 1 1 1 1 1 2 2 2 1 1 1 0 2 2 2 0 1 1 1 1),
      8: (0 0 0 0 0 0 0 0 0 0 1 1 1 0 2 2 2),
    );
    
    animation: $animation-front 6s linear infinite;
    bottom: $size * -8;
    @include buildSeaweed($seaweed-map);
    z-index: 15;
  }

  &--two {
    $seaweed-map: (
      8: (0 0 1 1 1 2 2 2 2 0 0 0 0 0 0 0 0 0 1 1 1 0 2 2 2),
      7: (0 0 1 1 1 1 2 2 2 2 0 0 0 0 0 0 0 0 1 1 1 1 1 2 2 2),
      6: (2 1 1 1 8 8 8 1 2 2 2 1 1 0 0 2 2 1 1 1 8 8 8 1 2 0 0 1 1),
      5: (1 1 1 8 1 1 2 8 8 1 1 1 1 1 1 2 1 1 1 8 1 1 2 8 1 1 1 1 1 1),
      4: (8 8 8 1 1 2 2 2 1 8 8 8 1 1 1 1 8 8 8 1 1 2 2 2 8 8 8 8 1 1 8 1),
      3: (1 1 1 1 1 2 2 2 1 1 1 1 8 8 8 8 1 1 1 1 1 2 2 2 1 1 1 1 8 8 1),
      2: (2 1 1 1 0 2 2 2 0 1 1 1 1 1 2 2 2 1 1 1 0 2 2 2 0 1 1 1 1),
      1: (0 0 0 0 0 0 0 0 0 0 1 1 1 0 2 2 2),
    );
    
    animation: $animation-back 7s linear 4s infinite;
    bottom: $size * -4;
    @include buildSeaweed($seaweed-map);
    z-index: 5;
  }
  
  &--three {
    animation: $animation-back 8s linear infinite;
    bottom: $size * -6;
    z-index: 5;
  }
  
  @keyframes #{$animation-front} {
    from {
      transform: translateX(100vw) translateZ(100px);
    }
    to {
      transform: translateX(-100vw) translateZ(100px);
    }
  }

  @keyframes #{$animation-back} {
    from {
      transform: translateX(100vw) translateZ(-100px);
    }
    to {
      transform: translateX(-100vw) translateZ(-100px);
    }
  }
}


body {
  min-height: 100vh;
  padding: 2rem;
}

* {
  &, &:before, &:after {
    box-sizing: border-box;
    &, &:focus, &:active, &:focus:active {
      outline: none;
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console