当前位置:网站首页>Charging effect simulation
Charging effect simulation
2022-07-31 01:39:00 【Gai Yuexi's boyfriend outside the circle (섭소우)】
Table of Contents
Thought analysis and code implementation
Demand
Continue to fish...
On a whim, how to achieve a mobile phone charging effect?Similar to...emmm is not easy to find, so omitted.In short, the dynamic effect that appears on the interface after the phone is connected to the charger.
Thought analysis and code implementation
This can obviously also be achieved with css animations.Displays the current battery level with a circle surrounded by solid-colored areas that are changing in color and shape.
It's not very easy to describe, just go to the code.
html section
82.5%css section
.container {width: 500px;min-height: 600px;background-color: black;margin: 0 auto;position: relative;}.circle {width: 300px;height: 300px;border-radius: 50%;margin: 100px auto;border: 3px solid white;color: white;background-color: black;line-height: 300px;text-align: center;font-size: 50px;position: relative;}/* clear margin overlap */.clearfix::before,.clearfix::after {content: '';display: table;clear: both;}.fire {width: 350px;height: 320px;position: absolute;top: calc(50% - 50px);left: 50%;transform: translate(-50%, -50%);}.fire-content{width: 100%;height: 100%;animation: rotate 10s infinite both reverse linear;}@keyframes rotate{from{transform: rotate(0);background-color: azure;border-radius: 260px 80px;}25%{transform: rotate(90deg);background-color: beige;border-radius: 80px 260px;}50%{transform: rotate(180deg);background-color: bisque;border-radius: 260px 80px;}75%{transform: rotate(270deg);background-color: powderblue;border-radius: 80px 260px;}100%{transform: rotate(360deg);background-color: honeydew;border-radius: 260px 80px;}}It's important to note here that confusion can arise when transform and animation are applied to the same element, and the animation also manipulates the transform.To do this, you can wrap a parent element outside the element, transform the parent element, and animate the child element.This way, there will be no confusion.
So, I manipulate fire-content with animation and fire with transform.
Achieving the effect

It's kind of like that!
Summary
This time the code is relatively simple, nothing special, just a point to pay attention to when applying animations and transforms.
When publishing, it indicates that the quality of the article is too low....Hey, let's go low!
边栏推荐
猜你喜欢

《实战》基于情感词典的文本情感分析与LDA主题分析

VSCode插件:嵌套注释

无线模块的参数介绍和选型要点

Teach you how to configure Jenkins automated email notifications

Basic Parameters of RF Devices 1

The sword refers to offer17---print the n digits from 1 to the largest

太阳能板最大面积 od js

基于Keras_bert模型的Bert使用与字词预测

成为比开发硬气的测试人,我都经历了什么?

剑指offer17---打印从1到最大的n位数
随机推荐
VS warning LNK4099:未找到 PDB 的解决方案
MySql的安装配置超详细教程与简单的建库建表方法
Ticmp - 更快的让应用从 MySQL 迁移到 TiDB
Word 表格跨页,仍然显示标题
uniapp使用第三方字体
Set the browser scrollbar style
充电效果模拟
【Map与Set】之LeetCode&牛客练习
手把手教你配置Jenkins自动化邮件通知
coldfusion文件读取漏洞(CVE-2010-2861)
什么是理想的大学生活?
简易表白小页面
keep-alive缓存组件
使用PageHelper实现分页查询(详细)
TiDB 在多点数字化零售场景下的应用
TiDB之rawkv升级之路v5.0.4-->v6.1.0
《实战》基于电商领域的词性提取及其决策树模型建模
蓝牙mesh系统开发二 mesh节点开发
1.非类型模板参数 2.模板的特化 3.继承讲解
《云原生的本手、妙手和俗手》——2022全国新高考I卷作文