The main text starts below. 123WORDPRESS.COM Download: Pure CSS3 to achieve ultra-realistic candle flame burning animation effect source code Today's tip is to use pure CSS to generate flames, more realistic flames. Well, what does it look like? Enter the keyword Or something like this: Could we go a step further, hopefully, using only CSS? Could it be like this: How to achieve it Well, we need to use Many flashy CSS effects are As shown in the picture above, the skeleton of the entire candle is very simple except for the flame part, so we will not talk about it in detail. Mainly let's take a look at how to generate the flame and how to give it animation effects. Step 1: filter blur && filter contrastThe blur filter is superimposed on the contrast filter to create a blended effect. Take out the two filters separately, their functions are:
However, when they "merged", a wonderful fusion phenomenon occurred. Let's look at a simple example: Look carefully at the process of the two circles intersecting. When the edges touch each other, a boundary fusion effect will be produced. The blurred edges of Gaussian blur are eliminated through the contrast filter, and the fusion effect is achieved using Gaussian blur. Using the above The specific implementation process of the flame-shaped triangle here is explained in detail in this article: CSS filter techniques and details you don’t know Adding Step 2: Flame Particle Animation It looks like it’s working, so let’s move on to the flame animation. Let’s remove Here we also use Next, we use SASS to give each small circle in the middle an animation that gradually disappears from bottom to top, and evenly assign different OK, the most important step is to turn on Step 3: Mix-blend-mode polish Of course, the above effects are already very good. After various attempts and adjusting parameters, I finally found that adding The full source code is on my CodePen: https://codepen.io/Chokcoco/pen/jJJbmz Some other effects Of course, once you've mastered this method, this technique for generating flames can be transferred to other effects as well. The picture below is another small demo I made. When hovering over an element, a flame effect is produced: CodePen Demo -- Hover Fire Well, these are actually some combinations of filters and blending modes. As usual, someone will definitely leave a message to criticize, saying what's the point of all these fancy things, the performance is not good, and if you dare to use them in business, I'll break your legs. For me, I humbly accept all kinds of criticisms, doubts and different opinions. Of course, I think that technology is practical on the one hand, and it is also a matter of interest and self-entertainment on the other. I hope the trolls will take a detour~ Back to the topic, after understanding this sticky and wet technique, you can also create many other interesting effects. Of course, you may need more attempts, such as the dripping effect achieved by using a label below: CodePen Demo -- Single label to achieve drip effect Details worth noting Although animation is beautiful, there are still some things to pay attention to during its specific use: CSS filters can define multiple filters for the same element at the same time, for example, In other words, using Filter animation requires a lot of calculations and constantly redraws the page. It is a very performance-intensive animation. Please pay attention to the usage scenario when using it. Remember to turn on hardware acceleration and use layering technology properly; This article only briefly introduces the whole thought process, and many CSS code details and debugging process are not shown. The main CSS properties are already known by default. You can learn more details after reading:
More wonderful CSS technical articles are collected in my Github -- iCSS. They are continuously updated. Welcome to click on the star to subscribe and collect. This is the end of this article on how to create a flame effect using CSS. For more information about CSS flame effects, please search previous articles on 123WORDPRESS.COM or continue browsing the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: Pitfalls and solutions encountered in MySQL timestamp comparison query
>>: Server stress testing concepts and methods (TPS/concurrency)
1. Custom text selection ::selection { background...
Preface Because of project needs, the storage fie...
This article records the creation of a USB boot d...
Table of contents front end According to the abov...
This article shares the installation and configur...
The first step is to create a mysql container doc...
For example, if your current path is /var/log and...
Web design is an emerging marginal industry that c...
This article shares with you how to use canvas an...
Because I wrote the word transition incorrectly i...
1. Download from the official website and unzip h...
What is a carousel? Carousel: In a module or wind...
After the National Day holiday, did any of you fi...
Table of contents Preface ErrorBoundary Beyond Er...
As shown below: As shown above, just replace it. ...