更新第39个小实例

This commit is contained in:
DESKTOP-BM6RJU5\wyanh 2021-11-11 17:46:05 +08:00
parent 00425b7353
commit 6bcf5004ea
3 changed files with 196 additions and 1 deletions

View File

@ -42,4 +42,5 @@
35. HTML5+CSS3小实例之超酷的文字滚动特效
36. HTML5+CSS3小实例之伸缩式动态搜索框
37. HTML5+CSS3小实例之JS+CSS实现日月交替效果
38. HTML5+CSS3小实例之3D分层按钮的悬停效果
38. HTML5+CSS3小实例之3D分层按钮的悬停效果
39. HTML5+CSS3小实例之手机充电特效

167
css/39.css Normal file
View File

@ -0,0 +1,167 @@
*{
/* 初始化 取消内外边距 */
margin: 0;
padding: 0;
}
body{
/* 100%窗口高度 */
height: 100vh;
background-color: #000;
}
.box{
width: 800px;
height: 100%;
margin: 0 auto;
/* 相对定位 */
position: relative;
}
/* 充电百分比 */
.number{
color: #fff;
position: absolute;
z-index: 1;
width: 200px;
height: 200px;
line-height: 200px;
text-align: center;
font-size: 30px;
left: 50%;
top: 25%;
margin-left: -100px;
}
.contrast{
width: 100%;
height: 100%;
background-color: #000;
position: relative;
/* 设置对比度 */
filter: contrast(15);
/* 指定动画:动画名 时长 线性的 无限次播放 */
animation: hueRotate 5s linear infinite;
}
/* 变色动画 */
@keyframes hueRotate {
0%{
/* contrast是设置对比度hue-rotate是颜色滤镜 通过设置度数来改变颜色 */
filter: contrast(15) hue-rotate(0);
}
100%{
filter: contrast(15) hue-rotate(360deg);
}
}
.circle{
width: 300px;
height: 300px;
position: absolute;
top: 20%;
left: 50%;
margin-left: -150px;
/* 设置模糊度配合上面的contrast可以产生粘性效果 */
filter: blur(8px);
/* 执行动画 */
animation: circleRotate 5s linear infinite;
}
/* 外圈 */
.circle::before{
content: "";
width: 200px;
height: 200px;
background-color: cyan;
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%;
}
/* 圆旋转动画 */
@keyframes circleRotate {
0%{
transform: rotate(0);
}
100%{
transform: rotate(360deg);
}
}
/* 冒泡的底座 */
.bubble-home{
width: 100px;
height: 40px;
background-color: cyan;
position: absolute;
left: 50%;
bottom: 0;
margin-left: -50px;
border-radius: 100px 100px 0 0;
filter: blur(8px);
}
.bubble{
width: 20px;
height: 20px;
background-color: cyan;
border-radius: 100%;
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
z-index: 2;
filter: blur(5px);
/* 执行动画:动画名 时长 加速后减速 无限次播放 */
animation: bubbleUp 5s ease-in-out infinite;
}
/* 接下来分别为每一个泡泡设置大小、位置、动画时长、动画延迟时间 */
.bubble:nth-child(1){
width: 20px;
height: 20px;
left: 50%;
animation-duration: 5s;
animation-delay: 1s;
}
.bubble:nth-child(2){
width: 22px;
height: 22px;
left: 49%;
animation-duration: 4s;
animation-delay: 2s;
}
.bubble:nth-child(3){
width: 24px;
height: 24px;
left: 47%;
animation-duration: 3s;
animation-delay: 3s;
}
.bubble:nth-child(4){
width: 18px;
height: 18px;
left: 53%;
animation-duration: 3s;
animation-delay: 4s;
}
.bubble:nth-child(5){
width: 26px;
height: 26px;
left: 51%;
animation-duration: 4s;
animation-delay: 5s;
}
/* 冒泡动画 */
@keyframes bubbleUp {
0%{
bottom: 0;
}
100%{
bottom: calc(80% - 260px);
}
}

27
html/39.html Normal file
View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>手机充电特效</title>
<link rel="stylesheet" href="../css/39.css">
</head>
<body>
<div class="box">
<div class="number">98.6%</div>
<div class="contrast">
<div class="bubble"></div>
<div class="bubble"></div>
<div class="bubble"></div>
<div class="bubble"></div>
<div class="bubble"></div>
<div class="bubble-home"></div>
<div class="circle"></div>
</div>
</div>
</body>
</html>