I am trying to get a wipe up animation to make a circle look like it\'s filling with water. I\'ve run into two errors, and haven\'t been able to even tackle
This can be achieved with a single div and a ::before pseudo element:
The #banner
is given border-radius: 50%
to create a circle and overflow: hidden
to clip its children inside it
The ::before
pseudo element is animated to 100% height and the animation is paused at 100% using the forwards value. It begins at the bottom with the use of bottom: 0
The background images would be applied in place of the black and blue backgrounds on #banner
and #banner::before
Compatibility: IE10+ and all modern browsers. The -webkit-
prefixed property is most likely no longer necessary for your keyframe animations. Check the browser compatibility chart over here on caniuse.com
I have added the cubic-bezier(.2,.6,.8,.4)
which is explained in @ChrisSpittles answer. It provides a neat effect!
#banner {
width: 300px;
height: 300px;
position: relative;
background: #000;
border-radius: 50%;
overflow: hidden;
}
#banner::before {
content: '';
position: absolute;
background: #04ACFF;
width: 100%;
bottom: 0;
animation: wipe 5s cubic-bezier(.2,.6,.8,.4) forwards;
}
@keyframes wipe {
0% {
height: 0;
}
100% {
height: 100%;
}
}