In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use pure css to achieve water wave animation, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
As the tool for generating gif is relatively weak (the mac version of gif recording generation tool that is easy to use online), I have to upload an original picture and make up for it by myself.
Next, let's study the principle and method of implementation.
Animation disassembly
To implement a curve in pure css, our first reaction is to use the border-radius attribute, for example, to implement a circle, we just need to set it as follows:
Border-radius {50%;}
To realize the ellipse, fan-shaped and semi-ellipse, you only need to set the fillets on different sides, as follows:
Border-radius: 50% 100% 40% 60%;}
The effect of the above code is as follows:
Let's imagine again, if it is a closed curve, can it be achieved in the same way?
We just need to change background to border and adjust the border-radius parameter. Next, let's take a look at a figure I drew with css, which you can refer to and learn:
Of course, using the same principle, we can achieve more interesting patterns, the author will not give examples here. Back to the point, let's take a look at the principle of water wave animation. First of all, we have realized the irregular animation, and the rest of the work is how to realize the wave and wave animation. With reference to the implementation scheme of the irregular figure above, the wave line can be made by similar cutting, as follows:
As can be seen from the above figure, we can use css's border-radius to make a rectangle and a rounded rectangle, and use transform to set the offset and rotation to achieve the bottom trimmed surface. Finally, we use animation animation to make it move to see the effect:
We just need to optimize the above animation to make the background softer, such as circle, container overflow and hiding, so that we can realize the water wave animation in the H5-Dooring editor. The css source code is as follows:
.dragPay {position: absolute; z-index: 99999; left: 414px; top: 156px; width: 60px; height: 60px; border-radius: 50%; border: 3px solid # 20c961; background: # ffffff; overflow: hidden; padding: 5px; box-sizing: border-box;} .dragPay .wave {position: relative; left:-8px; width: 60px Height: 60px; background-image: linear-gradient (- 180deg, # 8dec8a 13%, # 70cf23 91%); border-radius: 50%; line-height: 60px; text-align: center; font-size: 32px; cursor: pointer;} .dragPay. RoomMask {position: absolute; width: 120px; height: 120px; top: 0; left: 50%; border-radius: 40% Background-color: rgba (255,255,255,0.9); transform: translate (- 50%,-82%) rotate (0); animation: toRotate 10s linear-5s infinite; z-index: 20; pointer-events: none;} @ keyframes toRotate {50 {transform: translate (- 50%,-70%) rotate (180deg);} 100% {transform: translate (- 50%,-70%) rotate (360deg) }}
The structure of html is as follows:
⛽️
Of course, we can use pseudo elements to optimize the dom structure.
Thank you for reading this article carefully. I hope the article "how to use pure css to realize water wave animation" shared by the editor will be helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.