In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you how to use css to do aurora effect related knowledge points, the content is detailed, logic is clear, I believe most people still know too much about this knowledge, so share this article for your reference, I hope you can learn something after reading this article, let's take a look at it.
Can auroras be achieved with CSS?
Like this:
Emmm, this is a little awkward. However, recently I also tried to try, although it is impossible to simulate such a real effect, but using CSS can still make some similar special effects, today we will try it together.
After observing some pictures of the aurora, I found some of the more important elements in the aurora animation:
Bright gradient color based on dark background
Similar to the animation effect of water wave flow
Bright gradient colors we can try to use gradient simulation. As for the animation effect of water wave flow, this is what feturbulence does in the SVG filter, and the use of this filter has been mentioned repeatedly in my past articles.
In addition to gradients and SVG filters, we may also use mixed mode (mix-blend-mode), CSS filters and other enhancement effects.
OK, after you have a general idea, all that's left is to keep trying.
Step 1. Draw a dark background
First of all, we may need a dark background to represent our night sky. At the same time, dotted with some stars, the stars can be simulated using box-shadow, so that we can complete a night sky background in 1 p:
@ function randomNum ($max, $min: 0, $u: 1) {@ return ($min + random ($max)) * $u;} @ function shadowSet ($n, $size) {$shadow: 00 # fff; @ for $I from 0 through $n {$x: randomNum; $y: randomNum (500); $scale: randomNum ($size) / 10 $shadow: $shadow, # {$x} px # {$y} px 0 # {$scale} px rgba (255,255,255, .8);} @ return $shadow;}. G-wrap {position: relative; width: 350px; height: 500px; background: # 0b1a3a; overflow: hidden; &: before {content: "; position: absolute; width: 1px Height: 1px; border-radius: 50%; box-shadow: shadowSet (100,6);}
This step is relatively simple. With the help of SASS, we can get a background picture of the night sky like this:
Step 2. Use a gradient to outline the aurora
The next step is to use the gradient to draw an outline of the aurora.
It's actually a radial gradient:
. g-aurora {width: 400px; height: 300px; background: radial-gradient (circle at 100% 100%, transparent 45%, # bd63c1 55%, # 53e5a6 65%, transparent 85%);}
Step 3. Rotational stretch
At present, it seems that there is a little outline. Next, we transform the gradient effect by rotating and stretching.
. g-aurora {... Transform: rotate (45deg) scaleX
We can probably get this effect:
Step 4. Magical mixed mode transformation!
At this point, in fact, the prototype has already come out. But the color doesn't look like it. In order to blend with the dark background, we use the mixed mode mix-blend-mode here.
. g-aurora {... Transform: rotate (45deg) scaleX; mix-blend-mode: color-dodge;}
Something amazing happened. Look at the effect:
Image
The overall color looks more like the color of the aurora.
Step 5. Overlay SVG feturbulence filter
Next, to produce the effect of water ripple, we need to use the filter of SVG.
Let's add a filter for SVG and use CSS filter for reference
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.