[animation Xiaole] HTML + CSS cloud floating effect 072

Haihong Pro 2021-06-19 01:19:46
animation xiaole html css cloud


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><span></span></section>
</body>
</html>

CSS

html, body {

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

display: flex;
justify-content: center;
align-items: center;
background: #93b5cf;
}
section {

width: 650px;
height: 300px;
padding: 10px;
position: relative;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid white;
}
span {

position: relative;
animation: cloud 5s ease-in-out infinite;
background: white;
border-radius: 50%;
box-shadow: white 65px -15px 0 -4px, white 25px -25px, white 30px 10px, white 60px 15px 0 -10px, white 85px 5px 0 -5px;
height: 50px;
width: 50px;
margin-left: -60px;
}
span:after {

animation: cloud_shadow 5s ease-in-out infinite;
background: black;
border-radius: 50%;
content: '';
height: 15px;
width: 120px;
opacity: 0.2;
position: absolute;
left: 5px;
bottom: -60px;
}
@keyframes cloud {

50% {

transform: translateY(-20px);
}
}
@keyframes cloud_shadow {

50% {

transform: translateY(0px) scale(.7);
opacity: .05;
}
}

The principle,

step 1

Use span label , Set to

  • Relative positioning
  • Width 、 The height is 50px
  • Background color : white
span {

background: white;
height: 50px;
width: 50px;
position: relative;
}

The renderings are as follows
 Insert picture description here

step 2

utilize box-shadow attribute , by span add to 5 A shadow

 box-shadow: red 65px -15px 0 -4px, /* shadow 1*/
orange 25px -25px, /* shadow 2*/
yellow 30px 10px, /* shadow 3*/
green 60px 15px 0 -10px, /* shadow 4*/
blue 85px 5px 0 -5px; /* shadow 5*/

The renderings are as follows

 Insert picture description here

step 3

span Fillet

span {

border-radius: 50%;
}

The renderings are as follows
 Insert picture description here

step 4

take 5 The color of each shadow is changed to white

 box-shadow: white 65px -15px 0 -4px, /* shadow 1*/
white 25px -25px, /* shadow 2*/
white 30px 10px, /* shadow 3*/
white 60px 15px 0 -10px, /* shadow 4*/
white 85px 5px 0 -5px; /* shadow 5*/

The renderings are as follows

 Insert picture description here

step 5

take span Move left 60px

span {

margin-left: -60px;
}

Get a little white cloud

 Insert picture description here

step 6

by span Add animation

The animation effect is described as : The clouds move up and down

Use translateY Property right span Conduct y Axis ( In the vertical direction ) Moving up and down

  • initial (0%): Original location
  • middle (50%): Move up 20px
  • At the end of (100%): Original location

animation The animation code is :

animation: cloud 5s ease-in-out infinite;
@keyframes cloud {

/* Ignore 0% 100% because span You need to go back to where you were */
50% {

transform: translateY(-20px);
}
}

The renderings are as follows

 Insert picture description here

step 7

Use span::after Pseudo elements act as shadows of white clouds , Set to

  • Absolute positioning ( left: 5px bottom: -60px)
  • Height 15px Width 120px
  • Background color : black
  • Color transparency :0.2
span:after {

background: black;
content: '';
height: 15px;
width: 120px;
opacity: 0.2;
position: absolute;
left: 5px;
bottom: -60px;
}

The renderings are as follows

 Insert picture description here

step 8

span::after Fillet

span:after {

border-radius: 50%;
}

The renderings are as follows
 Insert picture description here

step 9

by span::after Add animation

effect

  • When the clouds move up , The shadow becomes smaller , The color lightens ;
  • Move down the , The shadows get bigger , dark
span:after {

animation: cloud_shadow 5s ease-in-out infinite;
}
@keyframes cloud_shadow {

50% {

transform: translateY(20px) scale(.7);
opacity: .05;
}
}

The final effect is as follows

 Insert picture description here

Be careful : You can see from the renderings that , Actually, the shadow is just the size 、 The color depth is changing , Its position has not changed . This is because span In the animation 50% moment ,span perform translateY(-20px), if span::after No implementation translateY(20px), that span::after Will move together 20px.( The essence here is that the two effects cancel out ; 了 , therefore span::after There's no change in the position of )

If span::after No settings translateY(20px)

Then there will be the following effect : The shadows are moving up and down

 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 ️
 Insert picture description here

版权声明
本文为[Haihong Pro]所创,转载请带上原文链接,感谢
https://qdmana.com/2021/06/20210605041624540u.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