Vue3实战笔记(37)—粒子特效登录页面

61 篇文章 1 订阅
61 篇文章 0 订阅


前言

上头了,再来一个粒子特效登录页面。


一、粒子特效登录页

登录页:


<template>
   
    <div>

      <vue-particles id="tsparticles" @particles-loaded="particlesLoaded"  :options="options"  />
<form>
  <h3>Login Here</h3>

  <label for="username">Username</label>
  <input type="text" placeholder="Email or Phone" id="username">

  <label for="password">Password</label>
  <input type="password" placeholder="Password" id="password">

  <button>Log In</button>
  <div class="social">
    <div class="go"><i class="fab fa-google"></i> Google</div>
    <div class="fb"><i class="fab fa-facebook"></i> Facebook</div>
  </div>
</form><div id="tsparticles"></div>
<form>
  <h3>Login Here</h3>

  <label for="username">Username</label>
  <input type="text" placeholder="Email or Phone" id="username">

  <label for="password">Password</label>
  <input type="password" placeholder="Password" id="password">

  <button>Log In</button>
  <div class="social">
    <div class="go"><i class="fab fa-google"></i> Google</div>
    <div class="fb"><i class="fab fa-facebook"></i> Facebook</div>
  </div>
</form>

    </div>
</template>

<script setup lang="ts" name="">
let themeableContainer;

import tsParticles from "@tsparticles/vue3";


const particlesLoaded = async (container: any) => {
    console.log("Particles container loaded", container);
};
const options =

{
    fpsLimit: 60,
    fullScreen: { enable: true },
    particles: {
      number: {
        value: 50
      },
      shape: {
        type: "circle"
      },
      opacity: {
        value: 0.5
      },
      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
      }
    },
    style: {
      filter: "blur(50px)"
    },
    detectRetina: true,
    themes: [
      {
        name: "light",
        default: {
          value: true,
          mode: "light"
        },
        options: {
          background: {
            color: "#f7f8ef"
          },
          particles: {
            color: {
              value: ["#5bc0eb", "#fde74c", "#9bc53d", "#e55934", "#fa7921"]
            }
          }
        }
      },
      {
        name: "dark",
        default: {
          value: true,
          mode: "dark"
        },
        options: {
          background: {
            color: "#080710"
          },
          particles: {
            color: {
              value: ["#004f74", "#5f5800", "#245100", "#7d0000", "#810c00"]
            }
          }
        }
      }
    ],
    emitters: {
      direction: "top",
      position: {
        x: 50,
        y: 150
      },
      rate: {
        delay: 0.2,
        quantity: 2
      },
      size: {
        width: 100,
        height: 0
      }
    }
  }
</script>

<style lang='scss' scoped>
*,
*:before,
*:after {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
form {
  height: 520px;
  width: 400px;
  background-color: rgba(255, 255, 255, 0.13);
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  border-radius: 10px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 40px rgba(8, 7, 16, 0.6);
  padding: 50px 35px;
}
form * {
  font-family: "Poppins", sans-serif;
  color: #000000;
  letter-spacing: 0.5px;
  outline: none;
  border: none;
}

@media (prefers-color-scheme: dark) {
  form * {
    color: #ffffff;
  }
}

form h3 {
  font-size: 32px;
  font-weight: 500;
  line-height: 42px;
  text-align: center;
}

label {
  display: block;
  margin-top: 30px;
  font-size: 16px;
  font-weight: 500;
}
input {
  display: block;
  height: 50px;
  width: 100%;
  background-color: rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  padding: 0 10px;
  margin-top: 8px;
  font-size: 14px;
  font-weight: 300;
}

::placeholder {
  color: #1b1b1b;
}

@media (prefers-color-scheme: dark) {
  ::placeholder {
    color: #e5e5e5;
  }
}

button {
  margin-top: 50px;
  width: 100%;
  background-color: #ffffff;
  color: #080710;
  padding: 15px 0;
  font-size: 18px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
}
.social {
  margin-top: 30px;
  display: flex;
}
.social div {
  background: red;
  width: 150px;
  border-radius: 3px;
  padding: 5px 10px 10px 5px;
  background-color: rgba(255, 255, 255, 0.27);
  color: #150f03;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .social div {
    color: #eaf0fb;
  }

  body {
    background: #000;
  }
}

.social div:hover {
  background-color: rgba(255, 255, 255, 0.47);
}
.social .fb {
  margin-left: 25px;
}
.social i {
  margin-right: 4px;
}
</style>

如果不成功仔细看第一篇文章,一步一步做,很简单的。实际效果要比图片好看多了,gif录糊了糊了。。。

在这里插入图片描述


总结

行到水穷处,坐看云起时

  • 8
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue粒子效果登录页面可以通过使用Vue.js和一些粒子效果库来实现。下面是一个简单的示例,使用了vue-particles库来创建粒子效果登录页面: 首先,确保你已经安装了Vue.jsvue-particles库。你可以使用npm或yarn安装它们: ``` npm install vue npm install vue-particles ``` 或者 ``` yarn add vue yarn add vue-particles ``` 接下来,在Vue组件中引入vue-particles库并使用它来创建粒子效果登录页面。你可以创建一个名为Login.vue的组件,并在其中添加以下代码: ```html <template> <div> <div id="particles"> <particles></particles> </div> <div class="login-container"> <!-- 登录表单内容 --> </div> </div> </template> <script> import Particles from "vue-particles"; export default { name: "Login", components: { Particles, }, }; </script> <style> #particles { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; } .login-container { /* 登录表单的样式 */ } </style> ``` 在上面的代码中,我们将vue-particles库引入为组件的局部组件,并将其放置在id为"particles"的div中。然后,我们在同一组件中添加了登录表单的内容。 最后,在你的应用程序中使用Login.vue组件来呈现登录页面。你可以在App.vue或任何其他主组件中使用Login组件: ```html <template> <div id="app"> <Login /> </div> </template> <script> import Login from "./components/Login.vue"; export default { name: "App", components: { Login, }, }; </script> <style> #app { /* 应用程序的样式 */ } </style> ``` 现在,你就可以通过运行你的Vue应用程序来看到具有粒子效果的登录页面了。 这只是一个简单的示例,你可以根据需要进行样式和布局的调整,并在登录表单中添加适当的字段和功能。另外,你还可以通过调整vue-particles库中的配置选项来自定义粒子效果的外观和行为。具体的配置选项可以在vue-particles的文档中找到。希望这能帮到你!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值