当前位置:   article > 正文

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

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

文章目录


前言

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


404特效

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


<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/tsparticles

const 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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333

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


总结

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/650041
推荐阅读
相关标签
  

闽ICP备14008679号