css分享一个vue框架的404带动画效果页面样式
CSS
2025-11-15 23:30:32
404页面几乎是所有网站中都必不可少的一个页面,这样一个极为重要却在某些意义上说又不重要的页面。
在其样式设计上经常性的容易被忽略,基于此一个美观通用的404样式就变得必要起来。
本篇文章就来分享一个美观、实用的404页面样式。
<template>
<div class="error-page">
<div class="error-container">
<!-- 背景装饰元素 -->
<div class="background-elements">
<div class="circle circle-1"></div>
<div class="circle circle-2"></div>
<div class="circle circle-3"></div>
<div class="floating-element el-1">404</div>
<div class="floating-element el-2">?</div>
<div class="floating-element el-3">!</div>
</div>
<!-- 主要内容 -->
<div class="error-content">
<div class="error-animation">
<div class="number">4</div>
<div class="planet">
<div class="crater"></div>
<div class="crater"></div>
<div class="crater"></div>
</div>
<div class="number">4</div>
</div>
<h1 class="error-title">页面迷失在太空</h1>
<p class="error-description">
抱歉,您寻找的页面已经飞往另一个星系。它可能已被移动、删除或从未存在过。
</p>
</div>
</div>
</div>
</template>
<script setup lang="ts">
</script>
<style scoped>
.error-page {
min-height: calc(100vh - 60px);
display: flex;
align-items: center;
justify-content: center;
position: relative;
overflow: hidden;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
.error-container {
position: relative;
z-index: 2;
}
.circle {
position: absolute;
border-radius: 50%;
background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
animation: float 6s ease-in-out infinite;
}
.circle-1 {
width: 100px;
height: 100px;
top: 10%;
left: 5%;
animation-delay: 0s;
}
.circle-2 {
width: 150px;
height: 150px;
bottom: 10%;
right: 5%;
animation-delay: 2s;
}
.circle-3 {
width: 80px;
height: 80px;
top: 50%;
right: 10%;
animation-delay: 4s;
}
.floating-element {
position: absolute;
font-size: 24px;
opacity: 0.1;
animation: float 8s ease-in-out infinite;
}
.el-1 {
top: 20%;
right: 15%;
animation-delay: 1s;
}
.el-2 {
bottom: 30%;
left: 10%;
animation-delay: 3s;
}
.el-3 {
top: 60%;
left: 20%;
animation-delay: 5s;
}
@keyframes float {
0%, 100% {
transform: translateY(0) rotate(0deg);
}
50% {
transform: translateY(-20px) rotate(180deg);
}
}
/* 错误动画 */
.error-animation {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 40px;
gap: 20px;
}
.number {
font-size: 120px;
font-weight: 900;
color: #4f46e5;
text-shadow: 4px 4px 0px rgba(79, 70, 229, 0.2);
animation: bounce 2s ease-in-out infinite;
}
.number:nth-child(1) {
animation-delay: 0.1s;
}
.number:nth-child(3) {
animation-delay: 0.2s;
}
@keyframes bounce {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-20px);
}
}
.planet {
width: 100px;
height: 100px;
background: linear-gradient(135deg, #ff6b6b, #ee5a24);
border-radius: 50%;
position: relative;
animation: rotate 10s linear infinite;
box-shadow: 0 10px 30px rgba(255, 107, 107, 0.3);
}
.planet::before {
content: '';
position: absolute;
top: 20%;
left: 20%;
width: 30px;
height: 30px;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
}
.crater {
position: absolute;
background: rgba(0, 0, 0, 0.2);
border-radius: 50%;
}
.crater:nth-child(1) {
width: 20px;
height: 20px;
top: 30%;
right: 20%;
}
.crater:nth-child(2) {
width: 15px;
height: 15px;
bottom: 25%;
left: 30%;
}
.crater:nth-child(3) {
width: 25px;
height: 25px;
bottom: 15%;
right: 40%;
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
/* 内容样式 */
.error-content {
text-align: center;
position: relative;
z-index: 3;
}
.error-title {
font-size: 2.5rem;
font-weight: 700;
color: #1f2937;
margin-bottom: 16px;
background: linear-gradient(135deg, #4f46e5, #7c3aed);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.error-description {
font-size: 1.2rem;
color: #6b7280;
line-height: 1.6;
margin-bottom: 40px;
max-width: 500px;
margin-left: auto;
margin-right: auto;
}
/* 响应式设计 */
@media (max-width: 768px) {
.error-container {
padding: 40px 20px;
}
.number {
font-size: 80px;
}
.planet {
width: 70px;
height: 70px;
}
.error-title {
font-size: 2rem;
}
.error-description {
font-size: 1rem;
}
}
@media (max-width: 480px) {
.error-animation {
gap: 10px;
}
.number {
font-size: 60px;
}
.planet {
width: 50px;
height: 50px;
}
.error-title {
font-size: 1.75rem;
}
}
</style>404样式效果展示

六月初字帖坊小程序
你想要的字帖模板及工具,这里都有!
907篇文章
30人已阅读
六月初