[animation Xiaole | CSS] 086. Cool water wave loading transition animation

Haibang Pro 2021-08-09 16:50:23
animation xiaole css cool water


Preface

Hello! buddy !
Thank you very much for reading Haihong's article , If there are mistakes in the text , You are welcome to point out ~
 
Self introduction. ଘ(੭ˊᵕˋ)੭
nickname : Sea boom
label : Program the ape |C++ player | Student
brief introduction : because C Language and programming , Then I turned to computer science , Lucky to have won the National Award 、 Provincial awards, etc , It has been insured . Currently learning C++/Linux( It's really, really hard ~)
Learning experience : Solid foundation + Take more notes + Knock more code + Think more + Learn English well !
 
【 Animation Xiaole 】 It's boring to study and live at ordinary times , Inadvertently on some pages 、 Application transition / There's a lot of interest in loading animation , I want to know how to achieve it ? Learn how to use it in your spare time css Achieve some simple animation effects , This article is only for your study notes , Record your study and life , Try to understand the principles of animation , A lot of “ eliminate ” Animation !

Effect display

 Insert picture description here

Demo Code

HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<section>
<div class="circle">
<div class="wave"></div>
</div>
</section>
</body>
</html>

CSS

/* Template css style For demonstration purposes only */
html, body {

margin: 0;
height: 100%;
}
body {

display: flex;
justify-content: center;
align-items: center;
background-color: #12383e;
}
section {

width: 650px;
height: 300px;
padding: 10px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
border-radius: 20px;
border: 18px solid white;
overflow: hidden;
}
section::before {

content: 'CSS';
width: 150px;
height: 150px;
text-align: center;
line-height: 250px;
background-color: #00cec9;
position: absolute;
top: -76px;
right: -76px;
transform: translate(50%, -50%);
font-size: 32px;
font-weight: 500;
font-family: sans-serif;
color: white;
transform: rotate(45deg);
}
section::after {

content: '';
position: absolute;
width: 100%;
height: 100%;
border: 10px solid white;
border-radius: 20px;
}
/* Implementation code */
.circle {

position: relative;
width: 200px;
height: 200px;
background: #b0f4ff;
border-radius: 50%;
overflow: hidden;
animation: loadingBreath 5s infinite linear;
}
.circle::before {

content: 'Loading...';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 18px;
letter-spacing: 2px;
color: #10a789;
font-family: sans-serif;
z-index: 2;
}
.circle::after {

content: '';
position: absolute;
width: 100%;
height: 25%;
bottom: 0;
background-image: linear-gradient(to top, #12c8e0, #36e9ff, #5ffbf1);
animation: loadingRun 5s linear infinite;
}
.wave::before {

content: '';
position: absolute;
left: -50%;
width: 200%;
height: 200%;
z-index: 1;
background-color: #85f7fb;
border-radius: 52% 25% 62% 69%/25% 38%;
animation: loadingWave 5s linear infinite;
}
.wave::after {

content: '';
position: absolute;
left: -50%;
width: 200%;
height: 200%;
z-index: 1;
background-color: #d0f4ff;
border-radius: 42% 38% 40% 62%/28% 35%;
animation: loadingWave 5s ease-in-out infinite;
}
/* Breathing lamp animation */
@keyframes loadingBreath {

0% {

box-shadow: 0 0 5px 0 #85f7fb;
}
25% {

box-shadow: 0 0 20px 0 #85f7fb;
}
50% {

box-shadow: 0 0 5px 0 #85f7fb;
}
75% {

box-shadow: 0 0 20px 0 #85f7fb;
}
100% {

box-shadow: 0 0 5px 0 #85f7fb;
}
}
/* Bottom liquid rise animation */
@keyframes loadingRun {

0% {

height: 25%;
}
100% {

height: 100%;
}
}
/* wave Animation */
@keyframes loadingWave {

0% {

top: -100%;
transform: rotate(0);
}
100% {

top: -200%;
transform: rotate(360deg);
}
}

The principle,

step 1

Analyze from the effect drawing

It can be divided into two parts

  • Containers
  • The waves

Two are used here div, One for circle class , One for wave class , Represent container and... Respectively wave

 <div class="circle">
<div class="wave"></div>
</div>

step 2

Set up circle class

  • Relative positioning
  • Width 、 The height is 200px
  • Background color :#b0f4ff
  • Round corners :50%
.circle {

position: relative;
width: 200px;
height: 200px;
background: #b0f4ff;
border-radius: 50%;
}

The renderings are as follows :

 Insert picture description here

step 3

utilize .circle::befor Pseudo elements

Used for display “Loading…” word

Set to

  • Absolute positioning
  • Place it in precise middle ( top: 50%; left: 50%; transform: translate(-50%, -50%);)
  • font size :18px
  • Color :#10a789;
  • z-index:2( Than 1 Just big Put its text at the top )
.circle::before {

content: 'Loading...';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 18px;
letter-spacing: 2px;
color: #10a789;
font-family: sans-serif;
z-index: 2;
}

The renderings are as follows :

 Insert picture description here

step 4

utilize .circle::after Pseudo elements

Set to

  • Absolute positioning (bottom: 0; )
  • Width :100%
  • Height :25%
  • The background color is gradient linear-gradient(to top, #12c8e0, #36e9ff, #5ffbf1);
.circle::after {

content: '';
position: absolute;
width: 100%;
height: 25%;
bottom: 0;
background-image: linear-gradient(to top, #12c8e0, #36e9ff, #5ffbf1);
}

The renderings are as follows :

 Insert picture description here

step 5

by .circle::after Add animation to pseudo elements

Make it gradually increase its height with time

You only need to specify two keyframes

  • initial position :height: 25%
  • End position :height: 100%
.circle::after {

animation: loadingRun 5s linear infinite;
}
@keyframes loadingRun {

0% {

height: 25%;
}
100% {

height: 100%;
}
}

The renderings are as follows :

 Insert picture description here

step 6

Yes circle Set hidden overflow

.circle {

overflow: hidden;
}

The renderings are as follows :

 Insert picture description here

step 7

Here's a note circle Hide overflow as well as circle::after Animation For separate analysis later

.circle {

/* overflow: hidden; */
}
.circle::after {

/* animation: loadingRun 5s linear infinite; */
}

And then we use wave Two pseudo elements of .wave::before、.wave::afte And cirle::after Wave effect

The first set wave::before

  • Absolute positioning (left: -50%;)
  • Width 、 The height is 200%
  • z-index:1
  • Background color :#85f7fb
  • border-radius: 52% 25% 62% 69%/25% 38%; a key
.wave::before {

content: '';
position: absolute;
left: -50%;
width: 200%;
height: 200%;
z-index: 1;
background-color: #85f7fb;
border-radius: 52% 25% 62% 69%/25% 38%;/* a key */
}

The renderings are as follows :

 Insert picture description here
notes :.wave::before z-index by 1 Greater than circile(0) Less than .circle::before(2)

by .wave::before Add animation

Effect description

While rotating itself Also rising

.wave::before {

animation: loadingWave 5s linear infinite;
}
@keyframes loadingWave {

0% {

top: -100%;
transform: rotate(0);
}
100% {

top: -200%;
transform: rotate(360deg);
}
}

The renderings are as follows :

 Insert picture description here

Empathy , Yes wave::after Make the same settings

Difference is that ç The fillet ratio of four sides is the same as before Different 、 It's lighter

border-radius: 42% 38% 40% 62%/28% 35%;
background-color: #d0f4ff;

Everything else is the same
 Insert picture description here
When wave::after、before When using the same animation

The renderings are as follows :

 Insert picture description here

step 8

Cancel circle Hide overflow as well as circle::after Animation

.circle {

overflow: hidden;
}
.circle::after {

animation: loadingRun 5s linear infinite;
}

The renderings are as follows :

 Insert picture description here

step 9

Finally cirlce Add a breathing lamp animation effect

.circle {

animation: loadingBreath 5s infinite linear;
}
```css
@keyframes loadingBreath {

0% {

box-shadow: 0 0 5px 0 #85f7fb;
}
25% {

box-shadow: 0 0 20px 0 #85f7fb;
}
50% {

box-shadow: 0 0 5px 0 #85f7fb;
}
75% {

box-shadow: 0 0 20px 0 #85f7fb;
}
100% {

box-shadow: 0 0 5px 0 #85f7fb;
}
}

Get the final renderings

 Insert picture description here

Conclusion

The article is only for study notes , Record from 0 To 1 A process of

I hope it will be of some help to you , If you have any mistakes, you are welcome to correct them ~

I am a Sea boom ଘ(੭ˊᵕˋ)੭

If you think it's ok , Please like it

Thank you for your support ️

Learning reference :

https://www.bilibili.com/video/BV1Ai4y1t7od
https://developer.mozilla.org/zh-CN/docs/Web/CSS/::before

 Insert picture description here

版权声明
本文为[Haibang Pro]所创,转载请带上原文链接,感谢
https://qdmana.com/2021/08/20210809164358423W.html

  1. HTML + CSS + JavaScript to achieve cool Fireworks (cloud like particle text 3D opening)
  2. HTML + CSS + JavaScript realizes 520 advertising love tree (including music), which is necessary for programmers to express themselves
  3. Solve the problem of Web front-end deployment server (it can be deployed online without a server)
  4. HTML + CSS + JS make wedding countdown web page template (520 / Tanabata Valentine's Day / programmer advertisement)
  5. What else can driverless minibus do besides "Park connection"?
  6. Cloud native leads the era of all cloud development
  7. NRM mirror source management tool
  8. Bring it to you, flex Jiugong
  9. Lolstyle UI component development practice (II) -- button group component
  10. Deconstruction assignment in ES6
  11. Luo 2 peerless Tang clan was officially launched. The official gave a key point, and the broadcast time was implied
  12. 20初识前端HTML(1)
  13. 当新零售遇上 Serverless
  14. 20 initial knowledge of front-end HTML (1)
  15. When new retail meets serverless
  16. [golang] - go into go language lesson 5 type conversion
  17. [golang] - go into go language lesson 6 conditional expression
  18. HTML5(八)——SVG 之 path 详解
  19. HTML5 (8) -- detailed explanation of SVG path
  20. 需要开通VIP以后页面内容才能复制怎么办?控制台禁用javascript即可
  21. Web前端|CSS入门教程(超详细的CSS使用讲解,适合前端初学者)
  22. 实践积累 —— 用Vue3简单写一个单行横向滚动组件
  23. Serverless 全能选手,再下一城
  24. What if you need to open a VIP to copy the page content? Just disable JavaScript on the console
  25. Web front end | CSS introductory tutorial (super detailed CSS explanation, suitable for front-end beginners)
  26. Practice accumulation - write a single line horizontal scroll component simply with vue3
  27. Dili Reba is thin again. She looks elegant and high in a strapless hollow skirt, and her "palm waist" is beautiful to a new height
  28. Serverless all-round player, next city
  29. The difference between MySQL semi synchronous replication and lossless semi synchronous replication
  30. Vue表单设计器的终极解决方案
  31. The ultimate solution for Vue form designer
  32. Nginx从理论到实践超详细笔记
  33. Yu Shuxin's red backless swimsuit is split to the waist and tail, with a concave convex figure and excessive color matching, and his face is white to dazzling
  34. Nginx ultra detailed notes from theory to practice
  35. 【动画消消乐|CSS】086.炫酷水波浪Loading过渡动画
  36. typecho全站启用https
  37. CCTV has another popular employee. The off-site interpretation is very professional, and the appearance ability is no less than that of Wang Bingbing
  38. [animation Xiaole | CSS] 086. Cool water wave loading transition animation
  39. Enable HTTPS in Typecho
  40. 50天用JavaScript完成50个web项目,我学到了什么?
  41. 根据JavaScript中原生的XMLHttpRequest实现jQuery的Ajax
  42. What have I learned from completing 50 web projects with JavaScript in 50 days?
  43. "My neighbor doesn't grow up" has hit the whole network. There are countless horse music circles, and actor Zhou Xiaochuan has successfully made a circle
  44. 根据JavaScript中原生的XMLHttpRequest实现jQuery的Ajax
  45. Implement the Ajax of jQuery according to the native XMLHttpRequest in JavaScript
  46. Implement the Ajax of jQuery according to the native XMLHttpRequest in JavaScript
  47. 30 + women still wear less T-shirts and jeans. If they wear them like stars, they will lose weight
  48. 数栈技术分享前端篇:TS,看你哪里逃~
  49. Several stack technology sharing front end: TS, see where you escape~
  50. 舍弃Kong和Nginx,Apache APISIX 在趣链科技 BaaS 平台的落地实践
  51. Abandon the landing practice of Kong and nginx, Apache apisik on the baas platform of fun chain technology
  52. 浪迹天涯king教你用elementui做复杂的表格,去处理报表数据(合并表头,合并表体行和列)
  53. 前端HTML两万字图文大总结,快来看看你会多少!【️熬夜整理&建议收藏️】
  54. Wandering around the world king teaches you to use elementui to make complex tables and process report data (merge header, merge table body rows and columns)
  55. 路由刷新数据丢失 - vuex数据读取的问题
  56. Front end HTML 20000 word graphic summary, come and see how much you can【 Stay up late to sort out & suggestions]
  57. Route refresh data loss - vuex data reading problem
  58. Systemctl系统启动Nginx服务脚本
  59. Systemctl system startup nginx service script
  60. sleepless