参考资料:1. https://juejin.im/post/5e070cd9f265da33f8653f00 2.
1.加载动画类型1:点点点过渡

点点点加载动画
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
<style>
/*main css*/
.dot-loading{display: flex;margin-top: 200px;}
.dot-loading>.dot{
width: 50px;
height: 50px;
border-radius: 50%;
margin-left: 25px;
margin-right: 25px;
position: relative;
}
.dot-loading>.dot:before{
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: inherit; /*inherit 继承父类*/
border-radius: inherit;
animation: kuosan 4s ease-out infinite;
}
/*建议使用scss,sass之类的css样式编译,写法会简单很多*/
/*具体样式可自行调整*/
.dot-loading>.dot:nth-child(1) {
background-color: #7ef9ff;
}
.dot-loading>.dot:nth-child(2) {
background-color: #89cff0;
}
.dot-loading>.dot:nth-child(3) {
background-color: #4682b4;
}
.dot-loading>.dot:nth-child(4) {
background-color: #0f52ba;
}
.dot-loading>.dot:nth-child(5) {
background-color: #000080;
}
.dot-loading>.dot:nth-child(2):before{
animation-delay: 0.4s;
}
.dot-loading>.dot:nth-child(3):before{
animation-delay: 0.8s;
}
.dot-loading>.dot:nth-child(4):before{
animation-delay: 1.2s;
}
.dot-loading>.dot:nth-child(5):before{
animation-delay: 1.6s;
}
@keyframes kuosan {
40%{
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(2.5);
opacity: 0;
}
}
</style>
</head>
<body>
<div id="app">
<dot-loading></dot-loading>
</div>
<script>
Vue.component('dot-loading', {
template: `
<div class="dot-loading">
<div class="dot" v-for="num in 5" :key="num"></div>
</div>
`
});
var vm = new Vue({
el: '#app'
});
</script>
</body>
</html>
2. 文本展示特效--渐显

渐显
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
<style>
/*init css*/
body {
display: flex;
flex-direction: column;
height: 100vh;
justify-content: center;
align-items: center;
background-color: black;
/*background-image: linear-gradient(rgba(16, 16, 16, 0.8), rgba(16, 16, 16, 0.8)), url(https://i.loli.net/2019/10/18/buDT4YS6zUMfHst.jpg);*/
background-size: cover;
}
/*main css*/
.font-animation-landIn {
display: flex;
flex-wrap: wrap;
line-height: 1.8;
font-size: 50px;
color: white;
font-family: Lora, serif;
white-space: pre;
}
.font-animation-landIn>span {
font-size: 50px;
animation: font-animation-landIn 0.8s ease-out both;
}
@keyframes font-animation-landIn {
from {
opacity: 0;
transform: translateY(-20%);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
</head>
<body>
<div id="app">
<!--注意,内容的空格也会被算计在内,所以注意好格式-->
<div class="font-animation-landIn">Ano hi watashitachi mada shirania no Fushigi no mo nogatrao desu</div>
<div class="font-animation-landIn">召唤师,你相信世界会毁灭吗? 黑暗的终结是光明,死亡的轮回是转生,邪恶的极致便是正义!</div>
</div>
<script>
var vm = new Vue({
el: '#app',
mounted() {
initFontAnimationLandIn()
}
});
function initFontAnimationLandIn(animationDelayInterval) {
// 动画识别--拥有class='font-animation-landIn'的样式的div数组
let landInTexts = document.querySelectorAll('.font-animation-landIn');
landInTexts.forEach(function (landInText) {
// 获取div中的文字内容
let letters = landInText.textContent.split('');
// 清除原内容
landInText.textContent = '';
letters.forEach(function (letter, index) {
// 插入增加了动画渲染的span
let span = document.createElement('span');
span.textContent = letter;
span.style.animationDelay = index * (animationDelayInterval? animationDelayInterval: 0.05) + 's';
landInText.append(span);
})
})
}
</script>
</body>
</html>
3. 文字展示特效--两边渐现

两边渐现
网友评论