视觉充电:CSS动画特效,为网站带来动力与活力!(一键复制)

简介: 视觉充电:CSS动画特效,为网站带来动力与活力!(一键复制)

先上效果


🌟 CSS实现的酷炫充电动画特效,能够直观地展示数据的增长或能量的累积,为用户提供一种新颖的视觉体验。本文将详细介绍如何使用CSS来创造一个充满动感的充电动画效果,无论是用于电池电量指示、数据加载进度,还是仅仅作为网页装饰,都能吸引用户的注意力,增加页面的吸引力。



完整代码


以下是完整代码:

HTML:

<div class="phoneBox">
        <div class="screenPhone">
            <div class="number">78.6%</div>
            <div class="ascending">
                <div class="water"></div>
                <div class="water"></div>
                <div class="water"></div>
                <div class="water"></div>
                <div class="water"></div>
                <div class="water-home"></div>
                <div class="circle"></div>
            </div>
        </div>
    </div>


CSS代码:


.phoneBox{
    margin: 20px auto;
    width: 375px;
    height: 765px ;
    background-size: cover;
    box-sizing: border-box;
    padding-top: 16px;
}
.screenPhone{
    width: 330px;
    height: 657px;
    margin: 0 auto;
    background: #000;
    border-radius: 45px 45px 0 0;
    position: relative;
}
.screenPhone .number{
    width: 200px;
    height: 200px;
    position: absolute;
    left: 50%;
    top: 15%;
    transform: translateX(-50%);
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5em;
    color: #fff;
}
/* 电量充电动画的大盒子 */
.screenPhone .ascending{
    width: 100%;
    height: 100%;
    background: #050807;
    border-radius: 45px 45px 0 0;
    position: relative;
}
/* 框选电脑显示区域 */
.screenPhone .circle{
    width: 300px;
    height: 300px;
    position: absolute;
    top: 7%;
    left: 50%;
    margin-left: -150px;
}
/* 伪元素设置电量周围颜色 */
.circle::before{
    content: "";
    width: 200px;
    height: 200px;
    background-color: #4dff03;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    border-radius: 42% 38% 63% 49%/45%;
}
/* 伪元素设置电量周围圆 */
.circle::after{
    content: "";
    width: 178px;
    height: 178px;
    background-color: #000;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    border-radius: 50%;
}
/* 设置向上泡泡的基本样式 */
.screen .water{
    width: 20px;
    height: 20px;
    background-color: #4dff03;
    border-radius: 100%;
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    z-index: 2;
}
/* 设置冒泡底座的基本样式 */
.water-home{
    width: 100px;
    height: 40px;
    background-color: #4dff03;
    position: absolute;
    left: 50%;
    bottom: 0;
    margin-left: -50px;
    border-radius: 100px 100px 0 0;
}
/* 调试滤镜 */
.screenPhone .ascending{
    /* 设置动画容器的对比度 */
    filter: contrast(15);
}
.screenPhone .circle{
    /* 设置电量周围颜色的模糊度 */
    filter: blur(8px);
}
.screenPhone .water{
    filter: blur(5px);
}
/* 设置旗袍底座的模糊度 */
.screenPhone .water-home{
    filter: blur(8px);
}
/* 添加动画 */
.screenPhone .ascending{
    animation: animation1 5s linear infinite;
}
/* 动画整体设置色相差 */
@keyframes animation1{
    0%{
        filter: contrast(15) hue-rotate(0);
    }
    100%{
        filter: contrast(15) hue-rotate(360deg);
    }
}
.screenPhone .circle{
    animation: animation2 5s linear infinite;
}
/* 设置电量周围的旋转 */
@keyframes animation2{
    0%{
        transform: rotate(0);
    }
    100%{
        transform: rotate(360deg);
    }
}
.screenPhone .water{
    animation: animation3 5s ease-in-out infinite;
}
/* 设置小气泡上升的动画 */
@keyframes animation3{
    0%{
        bottom: 0;
    }
    100%{
        bottom: calc(80% - 170px);
    }
}
/* 设置小气泡(位置 大小 动画时长 动画延迟) */
.water:nth-child(1){
    width: 20px;
    height: 20px;
    left: 50%;
    animation-duration: 5s;
    animation-delay: 1s;
}
.water:nth-child(2){
    width: 20px;
    height: 20px;
    left: 49%;
    animation-duration: 4s;
    animation-delay: 2s;
}.water:nth-child(3){
    width: 20px;
    height: 20px;
    left: 48%;
    animation-duration: 3s;
    animation-delay: 2s;
}.water:nth-child(4){
    width: 20px;
    height: 20px;
    left: 52%;
    animation-duration: 2s;
    animation-delay: 3s;
}.water:nth-child(5){
    width: 20px;
    height: 20px;
    left: 51%;
    animation-duration: 1s;
    animation-delay: 5s;
}.water:nth-child(6){
    width: 20px;
    height: 20px;
    left: 53%;
    animation-duration: 3s;
    animation-delay: 3s;
}
相关文章
|
12月前
|
前端开发 JavaScript 测试技术
CSS3 动画效果对网站性能有什么影响?
CSS3动画效果在为网站带来丰富视觉体验的同时,也会对网站性能产生多方面的影响
435 58
|
4月前
|
自然语言处理 前端开发 JavaScript
用 通义灵码 一键生成“水波纹按钮”,连 CSS 动画都不用自己写了!
通义灵码是一款智能编程辅助工具,它可以根据自然语言指令自动生成高质量的代码。例如,只需输入“生成一个按钮,点击时带水波纹动画,模拟 Material Ripple 效果”,它就能生成具备完整交互逻辑、CSS 动画和良好性能的按钮组件。不仅如此,它还支持拓展功能,如长按触发提示、添加图标等,并能自动优化样式适配不同场景。通过通义灵码,开发者可以大幅提升效率,专注于创意实现,而不必纠结于繁琐的代码细节。
|
9月前
|
前端开发 JavaScript
CSS 过渡和动画
CSS过渡和动画是用于为网页元素添加动态效果的两种重要技术
455 143
|
1月前
|
前端开发 算法 Java
【CSS】前端三大件之一,如何学好?从基本用法开始吧!(九):强势分析Animation动画各类参数;从播放时间、播放方式、播放次数、播放方向、播放状态等多个方面,完全了解CSS3 Animation
Animation属性 css3为Animation动画提供的几个属性如下: 属性名 属性值 animation-name 指定动画名称,该属性指定一个已有的关键帧定义。 animation-duration 指定动画持续时间。 animation-timing-funtion 指定动画变化速度。 animation-delay 指定动画延迟多长时间才开始执行。 animation-iteration-count 指定动画的循环执行次数。 animation:这是一个复合属性。
93 1
|
12月前
|
编解码 前端开发 UED
如何巧妙利用CSS3,打造炫酷视觉效果
在使用CSS3打造炫酷视觉效果时,要注意适度使用,避免过度设计导致页面过于复杂和混乱,影响用户的阅读和浏览体验。同时,要确保所使用的效果在不同的浏览器和设备上具有良好的兼容性,以提供一致的视觉效果。
406 137
|
10月前
css3 svg制作404页面动画效果HTML源码
css3 svg制作404页面动画效果HTML源码
188 34
|
12月前
|
移动开发 前端开发 JavaScript
除了 CSS3,还有哪些技术可以实现动画效果?
除了 CSS3,还有哪些技术可以实现动画效果?
348 63
|
12月前
|
JavaScript 前端开发
CSS3 动画和 JavaScript 动画的性能比较
具体的性能表现还会受到许多因素的影响,如动画的复杂程度、浏览器的性能、设备的硬件条件等。在实际应用中,需要根据具体情况选择合适的动画技术。
|
12月前
|
Web App开发 前端开发 JavaScript
如何在不牺牲动画效果的前提下,优化 CSS3 动画的性能?
如何在不牺牲动画效果的前提下,优化 CSS3 动画的性能?
578 58
|
10月前
jQuery+CSS3实现404背景游戏动画源码
jQuery+CSS3实现404背景游戏动画源码
153 22

热门文章

最新文章