1. 渐变背景动画:
@keyframes gradientAnimation {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
.gradient-bg {
background: linear-gradient(90deg, #ff8a00, #e52e71, #3494e6);
background-size: 200% 200%;
animation: gradientAnimation 3s infinite;
}
2. 旋转的加载动画:
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.spinner {
border: 16px solid #f3f3f3;
border-top: 16px solid #3498db;
border-radius: 50%;
width: 80px;
height: 80px;
animation: spin 2s linear infinite;
}
3. 跳动的文字:
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(-30px);
}
60% {
transform: translateY(-15px);
}
}
.bouncing-text {
animation: bounce 2s infinite;
}
4. 淡入淡出效果:
@keyframes fadeInOut {
0%, 100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
.fade-in-out {
animation: fadeInOut 2s infinite;
}
5. 闪烁的背景:
@keyframes blink {
0% {
background-color: #3498db;
}
50% {
background-color: #2ecc71;
}
100% {
background-color: #3498db;
}
}
.blinking-background {
animation: blink 2s infinite;
}
6. 3D按钮点击效果:
@keyframes clickEffect {
0% {
transform: scale(1);
}
50% {
transform: scale(0.9);
}
100% {
transform: scale(1);
}
}
.button-click {
transition: transform 0.3s ease;
}
.button-click:hover {
animation: clickEffect 0.3s ease-out;
}
这些是一些简单的CSS3动画特效示例,你可以根据具体的需求和创意进一步修改和定制。CSS3动画为网页增加了生动感和交互性,可以通过动画来吸引用户的注意力,提升用户体验。
转载请注明出处:http://www.zyzy.cn/article/detail/4080/CSS