Home>Article>Web Front-end> Pure CSS to realize the battery charging animation effect of water ripples
This article will introduce to you how to skillfully useCSSto achieve the battery charging animation effect of water ripples. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
We know that the three major languages that make up the front-end are:html
,css
andjs
, among which The most mysterious thing iscss
, why do you say that? Since the emergence of animation, transition and other attributes, it can be said that as long as you can’t think of it, there is nothing you can’t do ~
The previous article introduced a mobile phone charging animation effect, and I will continue it today. Compared with the previous article, The article is a bit simple, but for the sake of my girlfriend, I will write it here~
Special effects:Battery charging special effects, the overall special effects can be seen at the top
If you want to complete this special effect, you must know some prerequisite attributes. Let’s briefly introduce them:
animation,transformandfilterwill not be introduced in detail. Basically all animations will use these two properties. [Recommended learning:css video tutorial]
##box-shadow:Shadow
Usage: box-shadow: h-shadow v-shadow blur spread color inset;border-radius: Set rounded corners
You can set four values, which are the same asmarginand
padding
Upper left corner,
Upper right corner,
Lower right corner,
Lower left corner.
linear-gradient(): Gradient, used to create a gradient that represents two or more Picture of linear gradient of colors.
Usage:background-image: linear-gradient(direction, color-stop1, color-stop2, ...);
border-radius, and add
box -shadowAdd shadow to enhance the three-dimensional effect
##Charging effect
The position of the water. The larger the value oftop
, the lower the water. The smaller the value oftop
, the higher the water.We set the water level to 80% and pass
To set a gradient color of water:
Then the animation is very simple, you only need to control the
topvalue It will cause the water to rise, like this
The points that need to be noted at this time are:
Our container at the top has rounded corners. , so when the animation reaches 100%, it should be the same as the rounded corners of the container.
.content{ //容器 border-radius: 15px 15px 5px 5px; &::after{ position: absolute; top: 80%; background: linear-gradient(to bottom, #7abcff 0%, #00BCD4 44%, #2196F3 100%); border-radius: 0px 0px 5px 5px; box-shadow: 0 14px 28px rgba(33, 150, 243, 0), 0 10px 10px rgba(9, 188, 215, 0.08); animation: change 10s linear infinite; filter: hue-rotate(90deg); } } @keyframes change { 30% { box-shadow: 0 14px 28px rgba(0, 150, 136, 0.83), 0px 4px 10px rgba(8, 117, 134, 0.4); } 50%{ filter: hue-rotate(60deg); } 80% { top: 20%; border-radius: 0 0 5px 5px; box-shadow: 0 14px 28px rgba(6, 136, 153, 0.2), 0 10px 10px rgba(12, 10, 112, 0.08); } 100% { top: 0%; filter: hue-rotate(0deg); border-radius: 15px 15px 5px 5px; box-shadow: 0 14px 28px rgba(7, 93, 104, 0), 0 10px 10px rgba(31, 3, 68, 0.4); } }
Water ripple special effect
and then The
translateattribute is used, by converting the 此时,我们发现这个效果并不太真实,进行多覆盖两个,改变旋转值和 此时的效果就非常真实了 不得不说 (学习视频分享:web前端) The above is the detailed content of Pure CSS to realize the battery charging animation effect of water ripples. For more information, please follow other related articles on the PHP Chinese website!x
,y
values, and then by constantly rotating the angle. As for why the value is this value, I can’t figure it out. clear. . . Anyone who knows can leave a message in the comment area.p{ //复盖 border-radius: 45% 47% 44% 42%; transform: translate(-50%, 0); animation: move 10s linear infinite; } @keyframes move { 100% { transform: translate(-50%, -160px) rotate(720deg); } }
border-radius
的值来设置水面不重叠,但又有差距的效果p{ &:nth-child(2){ border-radius: 38% 46% 43% 47%; transform: translate(-50%, 0) rotate(-135deg); } &:nth-child(3){ border-radius: 42% 46% 37% 40%; transform: translate(-50%, 0) rotate(135deg); } }
End
css
真的很神奇,最神秘的莫过于css
,喜欢的点个赞??支持下吧(● ̄(エ) ̄●)