2

**enter image description here**

This custom graphic need to fill with three different colors. Every color will be filled with 1-100%. So blue color will be filled from leg to head ( 1-100% ), red color will be filled from bottom of the head to top of the head ( 1-100% ) and so the orange color. Can this possible using svg / canvas or any other way?

2
  • 2
    show what you have done Commented Sep 9, 2015 at 5:11
  • 1
    In SVG you can create 3 shapes and 3 colored rectangles and apply clipping. Commented Sep 9, 2015 at 8:40

1 Answer 1

5

CSS animation method

  1. Segment the three different color sections with different divs. Position it in the HTML according to the priority or give it z-index regardless of the markup.
  2. Sub divide the color sections for creating the holder and filling up background. Although this can be created with :before and :after I have used nested divs.
  3. Create a fill-up key frame animation which transitions from 0% height to 100% height. More info about the filling up animation can be found in these answers: CSS Wipe up animation
  4. The animation-delay needs to be calculated before, according to the number of shapes you have. If the first shape has a animation duration of 2s, give the next shape animation-delay of 2s which creates a sequential effect.

Manipulate the border-radius, position, width and height values to get the desired shape and position.

Edit: Updated with a status indicator in Codepen

Codepen Demo

body {
  background: lightgray;
}

/* Red Filler */

.red-filler {
  background: lightgray;
  border-radius: 50%;
  width: 200px;
  height: 200px;
  border: 10px solid white;
  position: relative;
  overflow: hidden;
}
.red-liquid {
  width: 100%;
  position: absolute;
  bottom: 0;
  animation: fill-up 6s ease forwards;
  animation-timing-function: cubic-bezier(.2, .6, .8, .4);
  background: #E63B44;
}

/* Orange Filler */

.orange {
  z-index: -1;
  position: absolute;
}
.orange-filler-1 {
  background: lightgray;
  border-radius: 50%;
  width: 200px;
  height: 200px;
  border: 10px solid white;
  position: relative;
  top: -50px;
  overflow: hidden;
}
.orange-liquid-1 {
  width: 100%;
  position: absolute;
  bottom: 0;
  border-bottom-left-radius: 25%;
  border-bottom-right-radius: 25%;
  animation: fill-up 3s ease forwards;
  animation-timing-function: cubic-bezier(.2, .6, .8, .4);
  animation-delay: 3s;
  background: #EC952E;
  overflow: hidden;
}
.orange-filler-2 {
  background: lightgray none repeat scroll 0 0;
  border-bottom-left-radius: 40%;
  border-bottom-right-radius: 40%;
  border-color: white;
  border-image: none;
  border-style: none solid solid;
  border-width: 0 10px 10px;
  height: 100px;
  left: 50px;
  overflow: hidden;
  position: relative;
  top: -74px;
  width: 100px;
}
.orange-liquid-2 {
  animation: fill-up 3s ease forwards;
  animation-timing-function: cubic-bezier(.2, .6, .8, .4);
  background: #EC952E;
  position: absolute;
  bottom: 0;
  width: 100%;
}

/* Blue Filler */

.blue {
  z-index: -2;
  position: absolute;
  top: 40px;
}
.blue-filler-1 {
  background: lightgray none repeat scroll 0 0;
  border-radius: 50%;
  height: 250px;
  overflow: hidden;
  position: relative;
  width: 260px;
  left: -20px;
  top: -10px;
}
.blue-liquid-1 {
  width: 100%;
  position: absolute;
  bottom: 0;
  border-bottom-left-radius: 40%;
  border-bottom-right-radius: 40%;
  animation: fill-up 2s ease forwards;
  animation-timing-function: cubic-bezier(.2, .6, .8, .4);
  animation-delay: 4s;
  background: #566EB1;
  overflow: hidden;
}
.blue-filler-2 {
  background: lightgray none repeat scroll 0 0;
  border-radius: 50%;
  height: 275px;
  left: -25px;
  overflow: hidden;
  position: relative;
  top: -100px;
  width: 275px;
}
.blue-liquid-2 {
  animation: fill-up 2s ease forwards;
  animation-timing-function: cubic-bezier(.2, .6, .8, .4);
  background: #566EB1;
  position: absolute;
  bottom: 0;
  width: 100%;
  animation-delay: 2s;
}
.blue-filler-3 {
  background: lightgray none repeat scroll 0 0;
  border-bottom-left-radius: 50%;
  border-bottom-right-radius: 50%;
  height: 110px;
  left: 35px;
  overflow: hidden;
  position: relative;
  top: -125px;
  width: 150px;
}
.blue-liquid-3 {
  animation: fill-up 2s ease forwards;
  animation-timing-function: cubic-bezier(.2, .6, .8, .4);
  background: #566EB1;
  position: absolute;
  bottom: 0;
  width: 100%;
}
/* Container for centering */

.container {
  margin: 0 auto;
  width: 500px;
  margin-top: 50px;
}
/* Animation Keyframe */

@keyframes fill-up {
  0% {
    height: 0;
  }
  100% {
    height: 100%;
  }
}
<div class="container">
  
  <!-- Red container -->
  <div class="red">
    <div class="red-filler">
      <div class="red-liquid"></div>
    </div>
  </div>
  
  <!-- Orange container -->
  <div class="orange">
    <div class="orange-filler-1">
      <div class="orange-liquid-1"></div>
    </div>
    <div class="orange-filler-2">
      <div class="orange-liquid-2"></div>
    </div>
  </div>
  
  <!-- Blue container -->
  <div class="blue">
    <div class="blue-filler-1">
      <div class="blue-liquid-1"></div>
    </div>
    <div class="blue-filler-2">
      <div class="blue-liquid-2"></div>
    </div>
    <div class="blue-filler-3">
      <div class="blue-liquid-3"></div>
    </div>
  </div>
  
</div>

Sign up to request clarification or add additional context in comments.

2 Comments

You just made my day :) Solved my problem very easily, thanks a ton Manoj. Keep it up.
And your comment made my day. Thanks for the appreciation! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.