使用Vue3写的一个鼠标移动产生光晕的一个效果 已发布到npm包

使用

css 复制代码
npm install vue-mouse-glow --save

然后直接在.vue文件下引用

html 复制代码
<script setup>
import { GlowCapture, Glow } from 'vue-mouse-glow';
</script>

主要是GlowCaptureGlow 组件 其中GlowCapture 组件的size 属性设置的是光晕的大小 Glow 组件的color 属性是设置光晕的颜色style属性是光晕遮罩层的样式

效果 -> 使用软件录制的GIF图效果看起来和实际效果有色差和帧数区别 实际效果自行拷贝示例代码演示

完整示例代码:

html 复制代码
<template>
  <div class="container">
    <GlowCapture class="demo-section" :size="600">
      <Glow color="rgb(41, 160, 202)" style="border-radius: 1rem;" class="glow-hover">
        <div class="glow-card green">
          <h2>蓝绿光晕效果</h2>
          <p>带有光晕的卡片</p>
        </div>
      </Glow>
      <Glow color="rgb(41, 69, 202, 1)" style="border-radius: 1rem;" class="glow-hover">
        <div class="glow-card blues">
          <h2>紫蓝光晕效果</h2>
          <p>带有光晕的卡片</p>
        </div>
      </Glow>
      <Glow color="rgb(137, 41, 202, 1)" style="border-radius: 1rem;" class="glow-hover">
        <div class="glow-card purples">
          <h2>紫色光晕效果</h2>
          <p>带有光晕的卡片</p>
        </div>
      </Glow>
      <Glow color="rgb(202, 41, 148, 1)" style="border-radius: 1rem;" class="glow-hover">
        <div class="glow-card pink">
          <h2>粉色光晕效果</h2>
          <p>带有光晕的卡片</p>
        </div>
      </Glow>
      <Glow color="rgb(202, 41, 81, 1)" style="border-radius: 1rem;" class="glow-hover">
        <div class="glow-card orange">
          <h2>橘红光晕效果</h2>
          <p>带有光晕的卡片</p>
        </div>
      </Glow>
      <Glow color="rgb(41, 202, 188, 1)" style="border-radius: 1rem;" class="glow-hover">
        <div class="glow-card darkGreen">
          <h2>墨绿光晕效果</h2>
          <p>带有光晕的卡片</p>
        </div>
      </Glow>
      <Glow color="rgb(41, 202, 103, 1)" style="border-radius: 1rem;" class="glow-hover">
        <div class="glow-card grassGreen">
          <h2>草绿光晕效果</h2>
          <p>带有光晕的卡片</p>
        </div>
      </Glow>
      <Glow color="rgb(184, 81, 33, 1)" style="border-radius: 1rem;" class="glow-hover">
        <div class="glow-card oranges">
          <h2>橙色光晕效果</h2>
          <p>带有光晕的卡片</p>
        </div>
      </Glow>
      <Glow color="rgb(206, 203, 22, 1)" style="border-radius: 1rem;" class="glow-hover">
        <div class="glow-card yellow">
          <h2>黄色光晕效果</h2>
          <p>带有光晕的卡片</p>
        </div>
      </Glow>
    </GlowCapture>
  </div>

        <div class="ccc">
        <div class="glow-cards">
          <h2>毛玻璃效果</h2>
          <p>带有光晕的卡片</p>
        </div>
        </div>
</template>

<script setup>
import { GlowCapture, Glow } from 'vue-mouse-glow';
</script>

<style scoped>
.container {
  min-height: 70vh;
  background-color: #000000;
  padding: 2rem;

}

.ccc {
  width: 100%;
  height: 300px;
  background: #0d9467;
  margin-top: 20px;
  padding-bottom: 10px;
  overflow: hidden;
}


.demo-section {
  display: flex;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.glow-cards{
  background: rgba(255, 255, 255, 0.05);
  border-radius: 1rem;
  margin-left:10px;
  margin-top: 10px;
  width: 300px;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.3s ease;
  box-shadow: 0 2px 2px 0 rgb(147, 197, 253);
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));

}

.glow-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 1rem;
  padding: 2rem;
  width: 300px;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.3s ease;
  box-shadow: 0 2px 2px 0 rgb(147, 197, 253);
   
}

.glow-hover:hover {
  transform: translateY(-5px) translateZ(0);
}

.glow-card:hover {
  transition: all .2s ease-in-out;
  box-shadow: 0 3px 3px 0 rgba(147, 197, 253, 0.5);
  
}

.glow-cards:hover{
  transition: all .2s ease-in-out;
  box-shadow: 0 3px 3px 0 rgba(147, 197, 253, 0.5);
  transform: translateY(-5px) translateZ(0);
}


.glow\:glow-card {
  border-color: var(--glow-color);
}

.glow-card h2 {
  font-size: 1.8rem;
  font-weight: bold;
  color: white;
  margin-bottom: 1rem;
  transition: color 0.3s ease;
}

.glow\:h2 {
  color: var(--glow-color);
}

.glow-card p {
  font-size: 1.1rem;
  line-height: 1.5;
  color: #94a3b8;
}

.glow\:glow-card h2 {
  text-shadow: 0 0 8px var(--glow-color);
}

.purple h2 {
  color: rgb(216, 180, 254);
}

.blue h2 {
  color: rgb(147, 197, 253);
}

.red h2 {
  color: rgb(252, 165, 165);
}

.red h2 {
  color: rgb(252, 165, 165);
}

.green h2 {
  color: rgb(41, 160, 202,1);
}

.blues h2 {
  color: rgb(41, 69, 202, 1);
}
.purples h2 {
  color: rgb(137, 41, 202, 1);
}
.pink h2 {
  color: rgb(202, 41, 148, 1);
}

.orange h2 {
  color: rgb(202, 41, 81, 1);
}
.darkGreen h2 {
  color: rgb(41, 202, 188, 1);
}
.grassGreen h2 {
  color: rgb(41, 202, 103, 1);
}
.oranges h2 {
  color: rgb(184, 81, 33, 1);
}
.yellow h2 {
  color: rgb(206, 203, 22, 1);
}

.glow-card:hover h2 {
  text-shadow: 0 0 8px currentColor;
  transform: translateY(-10px) translateZ(0);
}

.glow-cards:hover h2 {
  text-shadow: 0 0 8px currentColor;
  transform: translateY(-5px) translateZ(0);
}
</style>
相关推荐
gongzemin1 小时前
前端根据文件流渲染 PDF 和 DOCX 文件
前端·vue.js·express
BillKu3 小时前
Element Plus 对话框 el-dialog 和 抽屉 el-drawer 的使用注意项(使用 div 包裹)
javascript·vue.js·elementui
luckymiaow3 小时前
「从零到一打造现代桌面应用:基于 Electron + Vite + Vue3 + TypeScript 的高效开发模板」
前端·vue.js
layman05283 小时前
Vue 中的配置代理
前端·javascript·vue.js
AnyaPapa3 小时前
【解决方案】Vue 常见问题大全
前端·javascript·vue.js
浩宇软件开发3 小时前
JavaScript 数组常用方法 find, findIndex, filter, map, flatMap, some
前端·javascript·vue.js
陶甜也4 小时前
threejs 实现720°全景图,;两种方式:环境贴图、CSS3DRenderer渲染
前端·vue.js·css3·threejs
JiangJiang5 小时前
🔥 第一次在 React 项目中用 UnoCSS,这些坑我都踩了
前端·vue.js·react.js
iaku5 小时前
🔥深度剖析Vue3响应式系统与组合式API实战
vue.js