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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <h1>CSS3 Animated Whale Icon</h1>

<div class="whale-icon">
  
  <div class="whale-body">
    <div class="whale-body-inner">
      
      <div class="whale-eye"></div>
      <div class="whale-mouth"></div>
      <div class="whale-fin"></div>
      
    </div>
    
    <div class="whale-tail"></div>
  </div>
  
  <div class="whale-fountain">
    <div class="whale-fountain-drop"></div>
    <div class="whale-fountain-drop"></div>
    <div class="whale-fountain-drop"></div>
  </div>
  
</div>
            
          
!
            
              //variables
$whale-body: #156d83;
$whale-body-light: #65a7b3;
$whale-dark: #050608;
$whale-fountain: #3073b9;

//mixins
@mixin position-absolute ($top: null, $bottom: null, $left: null, $right: null) {
  position: absolute;
  top: $top;
  left: $left;
  right: $right;
  bottom: $bottom;
}

* {
  margin: 0px;
  padding: 0px;
}

h1 {
  text-align: center;
  margin-top: 30px;
  color: #1e3d5d;;
  font: {
    family: 'Indie Flower', cursive;
    size: 40px;
  }
}

//whale icon styles
.whale-icon {
  width: 295px;
  height: 300px;
  margin: 50px auto 0;
  position: relative;
}

//whale body styles
.whale-body {
  width: 235px;
  height: 235px;
  @include position-absolute($left: 0, $bottom: 0);
  
  &-inner {
    width: 225px;
    height: 225px;
    overflow: hidden;
    background-color: $whale-body;
    border-radius: 50%;
    @include position-absolute($top: 5px, $left: 5px);
    box-shadow: 0px -5px 0px 0px rgba($whale-body-light, 0.7),
                0px 5px 0px 0px rgba($whale-body, 0.9);
    
    &:before {
      content: "";
      display: block;
      width: 200%;
      height: 200%;
      background-color: $whale-body-light;
      @include position-absolute($top: 40%, $left: -50%);
      border-radius: 50%;
    }
    
    //whale eye styles
    .whale-eye {
      width: 30px;
      height: 30px;
      background-color: $whale-dark;
      border-radius: 50%;
      @include position-absolute($top: 77px, $left: 62px);
      
      &:before {
        content: "";
        display: block;
        width: 15px;
        height: 15px;
        background-color: #fff;
        border-radius: 50%;
        @include position-absolute($right: 0, $top: 0);
      }
    }
    
    //whale mouth styles
    .whale-mouth {
      width: 50px;
      height: 40px;
      border-right: 4px solid $whale-dark;
      border-radius: 48px;
      @include position-absolute($top: 106px, $left: -25px);
      transform: rotate(73deg);
    }
    
    //whale fin styles
    .whale-fin {
      width: 60px;
      height: 45px;
      background-color: $whale-body;
      @include position-absolute($top: 78px, $left: calc(50% + 10px));
      box-shadow: 0px 3px 0px 0px rgba($whale-body-light, 0.7),
                  0px -3px 0px 0px rgba(darken($whale-body, 10%), 0.9);
      border-radius: 38px 20px 50% 10px;
      transform: rotate(-132deg);
    }
  }
  
  //whale tail styles
  .whale-tail {
    @include position-absolute($left: calc(100% - 5px), $top: calc(50% - 39px));

    &:before,
    &:after {
      content: "";
      display: block;
      width: 51px;
      height: 39px;
      background-color: $whale-body;
    }
    
    &:before {
      border-radius: 50% 0;
      box-shadow: 0px -3px 0px 0px rgba($whale-body-light, 0.7);
    }
    
    &:after {
      border-radius: 0 50%;
      box-shadow: 0px 3px 0px 0px rgba(darken($whale-body, 15%), 0.9);
    }
  }
}

//whale fountain styles
.whale-fountain {
  width: 74px;
  height: 53px;
  @include position-absolute($top: 0, $left: 82px);
  
  @keyframes drop-1 {
    
    0% {
      transform: scale(0);
      left: 24px;
      bottom: -22px;
      opacity: 0;
    }
    
    50% {
      transform: scale(1);
      left: 0px;
      bottom: 0px;
      opacity: 1;
    }
    
    100% {
      transform: scale(1);
      left: 0px;
      bottom: 0px;
      opacity: 1;
    }
  }
  
  @keyframes drop-2 {
    
    0% {
      transform: rotate(90deg) scale(0);
      right: 24px;
      bottom: -22px;
      opacity: 0;
    }
    
    15% {
      transform: rotate(90deg) scale(0);
      right: 24px;
      bottom: -22px;
      opacity: 0;
    }
    
    65% {
      transform: rotate(90deg) scale(1);
      right: 0px;
      bottom: 0px;
      opacity: 1;
    }
    
    100% {
      transform: rotate(90deg) scale(1);
      right: 0px;
      bottom: 0px;
      opacity: 1;
    }
  }
  
  @keyframes drop-3 {
    
    0% {
      transform: rotate(45deg) scale(0);
      top: 100%;
      opacity: 0;
    }
    
    25% {
      transform: rotate(45deg) scale(0);
      top: 100%;
      opacity: 0;
    }
    
    75% {
      transform: rotate(45deg) scale(1);
      top: 0;
      opacity: 1;
    }
    
    100% {
      transform: rotate(45deg) scale(1);
      top: 0;
      opacity: 1;
    }
  }
  
  &-drop {
    background-color: $whale-fountain;
    border-radius: 50% 50% 0 50%;
    transform-origin: center;
    
    &:nth-child(1),
    &:nth-child(2) {
      width: 30px;
      height: 30px;
    }
    
    &:nth-child(1) {
      @include position-absolute($left: 24, $bottom: -22px);
      transform: scale(0);
      opacity: 0;
      animation: drop-1 1.8s cubic-bezier(0.08, 1.07, 0.18, 1.37) 0s infinite;
    }
    
    &:nth-child(2) {
      @include position-absolute($right: 24, $bottom: -22);
      transform: rotate(90deg) scale(0);
      opacity: 0;
      animation: drop-2 1.8s cubic-bezier(0.08, 1.07, 0.18, 1.37) 0s infinite;
    }
    
    &:nth-child(3) {
      width: 20px;
      height: 20px;
      @include position-absolute($top: 100%, $left: 0, $right: 0);
      margin: auto;
      transform: rotate(45deg) scale(0);
      animation: drop-3 1.8s cubic-bezier(0.08, 1.07, 0.18, 1.37) 0s infinite;
    }
  }
}
            
          
!
            
              //check challenge page - http://100dayscode.co.uk/

//check blog post - http://fox-hover.co.uk/codepen-challenge-whale
            
          
!
999px
Loading ..................

Console