针对“8款使用 CSS3 实现超炫的 Loading(加载)的动画效果”的完整攻略,我会结合Markdown格式进行详细的讲解,包含示例说明,具体如下:
1. 准备工作
首先,我们需要准备一些基本的资源文件,包括:
- HTML 文件
该文件包含了我们要添加 Loading 动画的页面内容。
- CSS 文件
该文件用于编写 Loading 动画的样式和相关属性。
- 相关图片素材
包括 Loading 动画的背景图片、加载图标等。
准备好以上的资源文件后,我们就可以愉快地开始制作超炫的 Loading 动画了。
2. 制作 Loading 动画
接下来,我们将针对8款使用 CSS3 实现超炫的 Loading(加载)的动画效果进行讲解,具体如下:
2.1 方块旋转 Loading 动画
示例代码:
<div class="loading-square-rotate">
<div class="loading-square-rotate-inner"></div>
</div>
.loading-square-rotate {
display: inline-block;
position: relative;
width: 64px;
height: 64px;
}
.loading-square-rotate-inner {
width: 100%;
height: 100%;
position: absolute;
animation: loading-square-rotate 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
@keyframes loading-square-rotate {
0% {
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
}
50% {
transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
}
100% {
transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
}
}
2.2 方块缩放 Loading 动画
示例代码:
<div class="loading-square-scale"></div>
.loading-square-scale {
display: inline-block;
position: relative;
width: 64px;
height: 64px;
}
.loading-square-scale::before {
content: "";
display: block;
margin: 0 auto;
width: 50%;
height: 50%;
background-color: white;
animation: loading-square-scale 1.2s infinite ease-in-out;
}
@keyframes loading-square-scale {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
2.3 音符跳动 Loading 动画
示例代码:
<div class="loading-notes">
<div class="loading-notes-before"></div>
<div class="loading-notes-after"></div>
</div>
.loading-notes {
position: relative;
display: inline-block;
width: 40px;
height: 40px;
}
.loading-notes-before {
content: "";
position: absolute;
top: 0;
left: 8px;
right: 8px;
height: 6px;
border-radius: 100px 100px 0 0;
background-color: #fff;
}
.loading-notes-after {
position: absolute;
top: 16px;
left: 0;
right: 0;
height: 24px;
border-radius: 20px;
background-color: #fff;
animation: loading-notes 1s infinite ease-in-out;
}
@keyframes loading-notes {
0% {
transform: translateY(0);
}
50% {
transform: translateY(-6px);
}
100% {
transform: translateY(0);
}
}
2.4 书籍翻页 Loading 动画
示例代码:
<div class="loading-book">
<div class="loading-book-page"></div>
<div class="loading-book-cover"></div>
</div>
.loading-book {
position: relative;
display: inline-block;
width: 40px;
height: 40px;
}
.loading-book-page {
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 50%;
background-color: #487eb0;
animation: loading-book-page 1.5s infinite ease-in-out;
}
.loading-book-cover {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 50%;
background-color: #44c767;
animation: loading-book-cover 1.5s infinite ease-in-out;
}
@keyframes loading-book-page {
0% {
transform: rotateY(0);
}
33% {
transform: rotateY(-180deg);
}
66%,
100% {
transform: rotateY(-360deg);
}
}
@keyframes loading-book-cover {
0% {
transform: rotateY(-180deg);
}
33% {
transform: rotateY(-360deg);
}
66%,
100% {
transform: rotateY(0);
}
}
2.5 内切圆 Loading 动画
示例代码:
<div class="loading-circle">
<div class="loading-circle-inner"></div>
</div>
.loading-circle {
position: relative;
display: inline-block;
width: 40px;
height: 40px;
}
.loading-circle-inner {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
width: 24px;
height: 24px;
border-radius: 50%;
border-top-color: #fff;
border-bottom-color: #fff;
border-style: solid;
border-width: 4px;
animation: loading-circle 0.75s infinite linear;
}
@keyframes loading-circle {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
2.6 点光谱 Loading 动画
示例代码:
<div class="loading-dots">
<div class="loading-dots-dot"></div>
<div class="loading-dots-dot"></div>
<div class="loading-dots-dot"></div>
</div>
.loading-dots {
position: relative;
display: inline-block;
width: 40px;
height: 40px;
align-content: center;
}
.loading-dots-dot {
position: relative;
height: 8px;
width: 8px;
border-radius: 50%;
background-color: #fff;
animation: loading-dots 1.4s infinite ease-in-out both;
}
.loading-dots-dot:nth-child(1) {
animation-delay: -0.24s;
}
.loading-dots-dot:nth-child(2) {
animation-delay: -0.12s;
}
@keyframes loading-dots {
0%,
80%,
100% {
transform: scale(0);
}
40% {
transform: scale(1);
}
}
2.7 波浪 Loading 动画
示例代码:
<div class="loading-wave">
<div class="loading-wave-bar"></div>
<div class="loading-wave-bar"></div>
<div class="loading-wave-bar"></div>
<div class="loading-wave-bar"></div>
<div class="loading-wave-bar"></div>
</div>
.loading-wave {
position: relative;
display: inline-block;
width: 64px;
height: 64px;
}
.loading-wave-bar {
position: absolute;
width: 4px;
height: 20px;
background-color: #fff;
bottom: 0;
margin-right: 10px;
border-radius: 2px;
animation: loading-wave 1s ease-in-out infinite;
}
.loading-wave-bar:nth-child(1) {
animation-delay: -0.4s;
}
.loading-wave-bar:nth-child(2) {
animation-delay: -0.3s;
}
.loading-wave-bar:nth-child(3) {
animation-delay: -0.2s;
}
.loading-wave-bar:nth-child(4) {
animation-delay: -0.1s;
}
.loading-wave-bar:nth-child(5) {
animation-delay: 0s;
}
@keyframes loading-wave {
0% {
height: 0;
}
50% {
height: 20px;
}
100% {
height: 0;
}
}
2.8 白色方块滚动 Loading 动画
示例代码:
<div class="loading-scroll"></div>
.loading-scroll {
position: relative;
display: inline-block;
width: 32px;
height: 32px;
transform: rotateZ(45deg);
}
.loading-scroll::before,
.loading-scroll::after {
content: "";
position: absolute;
left: -1px;
top: -1px;
width: 4px;
height: 4px;
background-color: #fff;
animation: loading-scroll 1.2s infinite ease-in-out;
}
.loading-scroll::before {
animation-delay: 0.2s;
}
.loading-scroll::after {
animation-delay: 0.4s;
}
@keyframes loading-scroll {
0% {
transform: translateY(0);
}
20% {
transform: translateY(0);
}
60% {
transform: translateY(24px);
}
80%,
100% {
transform: translateY(-32px);
}
}
3. 结束语
如此,我们就完成了8款使用 CSS3 实现超炫的 Loading(加载)的动画效果的完整攻略。通过以上的示例展示和代码解释,相信你能够轻松掌握其中的技能和技巧,为自己的网站增添更多的动感和时尚感。
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:8款使用 CSS3 实现超炫的 Loading(加载)的动画效果 - Python技术站