使用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>
相关推荐
奶糖 肥晨3 小时前
Uniapp 开发中遭遇「可选链赋值」语法陷阱:一次编译错误排查实录
javascript·vue.js·uni-app
belldeep3 小时前
python:Django 和 Vue.js 技术栈解析
vue.js·python·django
正义的大古4 小时前
OpenLayers地图交互 -- 章节十七:键盘缩放交互详解
javascript·vue.js·openlayers
薄雾晚晴5 小时前
大屏开发实战:封装自动判断、无缝衔接的文字滚动组件,告别文本截断烦恼
前端·javascript·vue.js
Beginner x_u5 小时前
前端八股文 Vue上
前端·javascript·vue.js·八股文
小刘鸭地下城5 小时前
Vue 3 开发完全指南:从基础到高级的最佳实践
vue.js
逃离疯人院5 小时前
Vue3模板编译优化:Patch Flags与Block Tree深度解析
vue.js
小岛前端5 小时前
sass-embedded:高性能版的 Sass
前端·vue.js
天蓝色的鱼鱼5 小时前
Vue Router 动态路由完全指南:灵活掌控前端路由
前端·vue.js
麦麦大数据6 小时前
D018 vue+django 旅游图谱推荐问答系统|neo4j数据库|智能问答
vue.js·django·echarts·知识图谱·旅游·neo4j·智能问答