Vue3实战笔记(36)—粒子特效完成炫酷的404

news/2024/9/24 4:14:40/

文章目录

  • 前言
  • 404特效
  • 总结


前言

昨天介绍了一个粒子特效小例子,不够直观,下面直接实战在自己的项目中实现一个好玩滴。


404特效

更改之前创建好的404.vue:

javascript">
<template><div class="container"><vue-particles id="tsparticles" @particles-loaded="particlesLoaded"  :options="options"  /><div class="content"><div class="message"><p class="message-heading">Error 404</p><p class="message-description">The page you are looking for was moved, removed, renamed or might never have existed.</p></div><div class="links"><a href="http://localhost:3000/"></a></div></div></div>
</template><script setup lang="ts" name="">
//路由器
import {RouterLink, useRouter} from 'vue-router'//tsParticles library - https://github.com/matteobruni/tsparticlesconst particlesLoaded = async (container: any) => {console.log("Particles container loaded", container);
};
const options = 
{fpsLimit: 80,fullScreen: { enable: true },particles: {number: {value: 33},shape: {type: "circle"},opacity: {value: 0.6},size: {value: 400,random: {enable: true,minimumValue: 200}},move: {enable: true,speed: 10,direction: "top",outModes: {default: "out",top: "destroy",bottom: "none"}}},interactivity: {detectsOn: "canvas",events: {resize: true}},detectRetina: true,themes: [{name: "light",default: {value: true,mode: "light"},options: {background: {color: "#f7f8ef"},particles: {color: {value: ["#3998D0", "#2EB6AF", "#A9BD33", "#FEC73B", "#F89930", "#F45623", "#D62E32", "#EB586E", "#9952CF"]}}}},{name: "dark",default: {value: true,mode: "dark"},options: {background: {color: "#080710"},particles: {color: {value: ["#3998D0", "#2EB6AF", "#A9BD33", "#FEC73B", "#F89930", "#F45623", "#D62E32", "#EB586E", "#9952CF"]}}}}],emitters: {direction: "top",position: {x: 50,y: 150},rate: {delay: 0.2,quantity: 2},size: {width: 100,height: 0}}}
</script><style lang="scss" scoped>.return-home {display: block;float: left;width: 110px;height: 36px;background: #fff;border-radius: 100px;text-align: center;color: #ffffff;opacity: 0;font-size: 14px;line-height: 36px;cursor: pointer;}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section {display: block
}body {line-height: 1
}ol,ul {list-style: none
}blockquote,q {quotes: none
}blockquote:after,blockquote:before,q:after,q:before {content: "";content: none
}table {border-collapse: collapse;border-spacing: 0
}body {padding: 0;margin: 0;font-size: 18px
}.container {min-height: 100vh;position: relative;padding: 240px 0;box-sizing: border-box
}.overlay {position: absolute;top: 0;left: 0;width: 100%;height: 100%;overflow: hidden
}.content {position: absolute;top: 50%;left: 50%;width: 100%;transform: translate(-50%,-50%)
}.message {text-align: center;color: #fff
}.message-heading {font-family: "Share Tech Mono";font-weight: 900;text-transform: uppercase;letter-spacing: .7em;font-size: 2rem;padding: 0 0 0 1.4em
}.message-description {font-family: "Space Mono";line-height: 42px;font-size: 15px;letter-spacing: .15rem;padding: 0 20px;max-width: 600px;margin: auto
}.links {max-width: 600px;margin: 40px auto 0;text-align: center
}.links a {width: 170px;display: inline-block;padding: 15px 0;margin: 0 15px;border: 1px solid #000;color: #000;text-decoration: none;font-family: "Space Mono";text-transform: uppercase;font-size: 11px;letter-spacing: .1rem;position: relative
}.links a:before {content: "";height: 42px;background: #000;position: absolute;top: 0;right: 0;width: 0;transition: all .3s
}.links a:after {transition: all .3s;z-index: 999;position: relative;content: "back to hompage"
}.links a:hover:before {width: 170px
}.links a:hover:after {color: #fff
}.links a:nth-child(2) {background: #fff;color: #000
}.links a:nth-child(2):before {background: #212121;left: 0
}.links a:nth-child(2):after {content: "report error"
}.links a:nth-child(2):hover:after {color: #fff
}.social {position: absolute;bottom: 15px;left: 15px
}.social-list {margin: 0;padding: 0;list-style-type: none
}.social-list li {display: inline-block;margin: 5px 10px
}.social-list li a {color: #000
}@media (max-width: 480px) {.message-heading {font-size:1rem;margin-bottom: 30px}.message-description {font-size: .7rem;line-height: 2rem}.links a {margin: 10px;width: 280px}.social {left: 50%;margin-left: -55px}
}
</style>

完事儿了!就这么简单。看看效果:
在这里插入图片描述
动图还是很酷的,复制过去试试吧。


总结

一切福田,不离方寸;从心而觅,感无不通。


http://www.ppmy.cn/news/1463501.html

相关文章

2024年【山东省安全员C证】考试及山东省安全员C证报名考试

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 2024年【山东省安全员C证】考试及山东省安全员C证报名考试&#xff0c;包含山东省安全员C证考试答案和解析及山东省安全员C证报名考试练习。安全生产模拟考试一点通结合国家山东省安全员C证考试最新大纲及山东省安全员…

【程序员如何送外卖】

嘿&#xff0c;咱程序员要在美团送外卖&#xff0c;那还真有一番说道呢。 先说说优势哈&#xff0c;咱程序员那逻辑思维可不是盖的&#xff0c;规划送餐路线什么的&#xff0c;简直小菜一碟。就像敲代码找最优解一样&#xff0c;能迅速算出怎么送最省时间最有效率。而且咱平时…

Cocos Creator 声音播放与管理详解

Cocos Creator 是一款非常流行的游戏开发引擎&#xff0c;它提供了丰富的功能和工具&#xff0c;让开发者可以轻松构建出高质量的游戏。在游戏开发中&#xff0c;声音是一个非常重要的元素&#xff0c;可以为游戏增添氛围和趣味性。在本文中&#xff0c;我们将详细介绍Cocos Cr…

虹科Pico汽车示波器 | 免拆诊断案例 | 2017款奔驰E300L车行驶中发动机偶尔无法加速

故障现象 一辆2017款奔驰E300L车&#xff0c;搭载274 920发动机&#xff0c;累计行驶里程约为21万km。车主反映&#xff0c;该车行驶中发动机偶尔无法加速&#xff0c;且车辆发闯。 故障诊断 用故障检测仪检测&#xff0c;发动机控制单元&#xff08;N3/10&#xff09;中存储…

专业渗透测试 Phpsploit-Framework(PSF)框架软件小白入门教程(八)

本系列课程&#xff0c;将重点讲解Phpsploit-Framework框架软件的基础使用&#xff01; 本文章仅提供学习&#xff0c;切勿将其用于不法手段&#xff01; 继续接上一篇文章内容&#xff0c;讲述如何进行Phpsploit-Framework软件的基础使用和二次开发。 现在&#xff0c;我们…

51单片机-实机演示(单多个数码管)

仿真链接&#xff1a; http://t.csdnimg.cn/QAPhx 目录 一.引脚位置 二.多个显示 三 扩展 一.引脚位置 注意P00 - >A ; 这个多个的在左边,右边的A到B是控制最右边那个单个的. 接下来上显示单个的代码 #include <reg52.h> #include <intrins.h> #define u…

基于redis的分布式锁解决token续期冲突的问题

场景&#xff1a;用户登录状态存储到redis&#xff0c;2小时后过期。在过期前的30分钟如果用户进行操作&#xff0c;则对登录状态进行续期&#xff0c;续期后仍有2小时时限&#xff0c;并更换新的token。在微服务模式下&#xff0c;如果两个服务同时请求续期&#xff0c;则会返…

万博智云×华为云 | HyperBDR云容灾上架,开启联营联运新篇章

日前&#xff0c;万博智云HyperBDR云容灾正式入驻华为云云商店&#xff0c;成为华为云基础软件领域联营联运合作伙伴。通过联营联运&#xff0c;双方将进一步加深在产品、解决方案、渠道拓展等多方面的强强联合&#xff0c;为企业提供更加安全、高效的数据保护解决方案&#xf…