As mentioned before, css3 can replace many effects achieved by js. In fact, many times pure css3 can even replace pictures. You can draw some simple pictures directly using css3. Although the effect of pictures drawn with CSS3 may not be as good as using pictures directly, the implementation is also more complicated. The most troublesome thing is the compatibility issue, which is not as direct and practical as pictures. But thinking about solutions to problems in a different way can often inspire us and help us learn CSS3.
The demo given below will compare the windmill effect achieved with pictures and pure CSS3.
Let’s take a look at the static renderings first:
Windwheel animation renderings implemented with pure CSS3
The following is a brief introduction to how I use pure CSS3 To realize the animation effect of a windmill,
1. Draw the pillars of the windmill
We can see that the pillars of the windmill are an equilateral trapezoid. Through width, With the height attribute and border, we can realize many geometric figures, such as triangles, trapezoids, etc. You can refer to the trapezoid implementation method below to try the implementation of other figures yourself.
Achieving the effect of windmill columns
2. Draw the axis of the windmill
This step is relatively simple and can be easily achieved using the border-radius fillet attribute.
width:4px;
width: 2px;
border-width: 50px 2px 0px 2px; : solid solid none;
border-color: white transparent transparent ;
4. Position the pinwheel page
Windmill fan page to achieve the effect
Use the above method to draw three windmill fans in sequence, and position the angles.
The following is the implementation of animation
@-webkit-keyframes rotate{from{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate (360deg)}}
Put the implemented animation method rotate into our axis element, and the fan page can move.
-webkit-animation: rotate 4s linear infinite;
6. Improve effects and achieve compatibility