cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              .magic-garden
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--sm
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--sm
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--lg
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--lg
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--sm
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--sm
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--lg
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--lg
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--sm
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--sm
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--lg
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--lg
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--sm
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--sm
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--lg
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--lg
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--sm
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--sm    
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--lg
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--lg
  ul.shrooms
    each i in new Array(4)
      li.shroom.shroom--sm
        ul
          each i in new Array(6)
            li.shroom__dot.shroom__dot--sm
            
          
!
            
              // Testing bits of CSS Variables + CSS Grid Layout 

// COLOR CSS VARIABLES
:root {
  --c-01: #f5def0; // Light Purple
  --c-02: #7a4386; // Dark Purple
  --c-03: #cd7cbd; // Purple
  --c-04: #eaf3ee; // Light Green
  --c-05: #407e60; // Dark Green
  --c-06: #96c4ae; // Green
  --c-07: #f8ecda; // Light Yellow
  --c-08: #b0803a; // Dark Yellow
  --c-09: #e7bd7f; // Yellow
}

// SIZE VARIABLES
$stem_w: 20px; // Resize shrooms by editing only this variable
$stem_h: round($stem_w / 1.4);
$stem_r: round($stem_h / 12);
$stem_w2x: round($stem_w * 2);
$stem_h2x: round($stem_h * 2);
$stem_r2x: round($stem_r * 2);
$cap_w: round($stem_w * 2.2);
$cap_h: round($cap_w / 1.8);
$cap_r: round($stem_w * 1.5);
$cap_w2x: round($cap_w * 2);
$cap_h2x: round($cap_h * 2);
$cap_r2x: round($cap_r * 2);
$dot_lg: round($stem_w / 1.3);
$dot_sm: round($dot_lg / 2);
$dot_top: round($cap_h * 1.2);

// MIXINS
@mixin size($w, $h: $w) {
  width: $w;
  height: $h;
}

@mixin cap($w, $h, $r) {
  @include size($w, $h);
  border-top-left-radius: $r;
  border-top-right-radius: $r;
}

@mixin stem($w, $h) {
  @include size($w, $h);
  margin-left: calc(50% - (#{$w} / 2));
}

@mixin dots($size) {
  @for $i from 1 through 6 {
    &:nth-child(#{$i}) {
      @if $i==1 or $i==2 or $i==3 {
        @include size($size);
      }
      @else if $i==4 or $i==5 {
        @include size(round($size / 1.6));
      }
      @else if $i==6 {
        @include size(round($size / 1.3));
      }
    }
  }
}

@mixin animate_color($name) {
  animation: $name 12s 100 ease-in;
  transform: translateZ(0); // Let's reduce CPU usage
}

// LAYOUT
body,
ul {
  margin: 0;
  padding: 0; 
}

body {
  @include animate_color(color_bg);
  background-color: var(--c-01);
  overflow: hidden;
}

ul {
  list-style-type: none;
}

// ILLUSTRATION
.magic-garden {
  @include size(100vw, 100vh);
  display: flex; // Simply add a fallback if grid is not supported
  // CSS Grid Layout starts
  display: grid;
  grid-auto-flow: column;
  justify-content: center;
  align-items: center;
  // CSS Grid Layout ends
  overflow: hidden;
}

.shroom {
  &s {
    margin-left: $stem_w;
    margin-right: $stem_w;
  }
  
  @include animate_color(color_cap);
  background-color: var(--c-03);
  position: relative;
  
  &--sm,
  &--lg {
    &:after {
      @include animate_color(color_stem_dots);
      background-color: var(--c-02);
      content: '';
      position: absolute;
      left: 0;
    }
  }
  
  &--sm {
    @include cap($cap_w, $cap_h, $cap_r);
    margin-top: 160%;
    margin-bottom: 170%;
    
    &:after {
      @include stem($stem_w, $stem_h);
      border-radius: $stem_r;
      bottom: -$cap_h;
    }
    
    ul {
      @include size(100%, $cap_h);
      position: absolute;
      top: -$dot_top;
    }
  }
  
  &--lg {
    @include cap($cap_w2x, $cap_h2x, $cap_r2x);
    margin-top: 43%;
    margin-bottom: 70%;
    
    &:after {
      @include stem($stem_w2x, $stem_h2x);
      border-bottom-left-radius: $stem_r2x;
      border-bottom-right-radius: $stem_r2x;
      bottom: -$stem_h2x;
    }
    
    ul {
      @include size(100%, $cap_h2x);
    }
  }
  
  &__dot {
    background-color: var(--c-02);
    border-radius: 50%;
    position: absolute;
    // Firefox Fix: Jagged Edges
    transform-style: preserve-3d;
    outline: 1px solid transparent;
    
    @for $i from 1 through 6 {
      &:nth-child(#{$i}) {
        animation: float 0.6s ($i * 0.2s) infinite ease-in-out alternate;
        transform: translate3d((15% + $i), (15% - $i), 0) rotate(0.001deg);
        
        @if $i==1 {
          top: 56%;
          left: 9%;
        }
        @else if $i==2 {
          top: 14%;
          left: 33%;
        }
        @else if $i==3 {
          top: 50%;
          right: 9%;
        }
        @else if $i==4 {
          top: 60%;
          left: 34%;
        }
        @else if $i==5 {
          top: 25%;
          right: 28%;
        }
        @else if $i==6 {
          top: 62%;
          right: 32%;
        }
      }
    }
    
    &--sm {
      @include dots($dot_sm);
    }
    
    &--lg {
      @include dots($dot_lg);
    }
  }
}

// ANIMATIONS
@keyframes float {
  100% {
    transform: translate3d(0, 0, 0) rotate(0.001deg);
  }
}

@keyframes color_bg {
  0%,
  30% {
    background-color: var(--c-01);
  }
  33%,
  63% {
    background-color: var(--c-04);
  }
  66%,
  98% {
    background-color: var(--c-07);
  }
}

@keyframes color_cap {
  0%,
  30% {
    background-color: var(--c-03);
  }
  33%,
  63% {
    background-color: var(--c-06);
  }
  66%,
  98% {
    background-color: var(--c-09);
  }
}

@keyframes color_stem_dots {
  0%,
  30% {
    background-color: var(--c-02);
  }
  33%,
  63% {
    background-color: var(--c-05);
  }
  66%,
  98% {
    background-color: var(--c-08);
  }
}
            
          
!
            
              /* 
 * PURE CSS SHROOMS
 * Weekly CSS Illustration #08
 * Resizable shrooms with just 1 Sass edit.
 * Inspired by a dribbble illustration I created in 2013:
 * https://dribbble.com/shots/1140412-Shrooms
 * By ilithya | 2017
 */
            
          
!
999px
Loading ..................

Console