vue手搓悬浮在线客服按钮

html 复制代码
<template>
  <div id="app">
  <Header></Header>
    <!-- 悬浮按钮 -->
    <div class="floating-module">
        <button class="floating-button" id="online-service" @click="kefu()">
            <img src="@/assets/icon/客服.png" alt="在线客服">
        </button>
        <button class="floating-button" id="phone-service" @click="dianhua()">
            <img src="@/assets/icon/电话.png" alt="电话咨询">
        </button>
    </div>

    <!-- 路由挂载 -->
    <router-view></router-view>

  <Footer></Footer>
  </div>
</template>

<script>
import Header from '@/components/Header/Header'
import Footer from '@/components/Footer/Footer'

export default {
  name: 'App',
  components: {
    Header,
    Footer
  },
  methods:{
    kefu(){
      alert('客服')
    },
    dianhua(){
      alert('电话')
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* text-align: center; */
  /* color: #2c3e50; */
  /* margin-top: 60px; */
  /* padding-top:100px; */
}
a{
  text-decoration: none;
  color: #000000;
}
li{
  list-style: none;
}
*{
  margin: 0;
  padding: 0;
}
@media screen and (max-width:768px) {
  /* #app {
    padding-top:200px;
  } */
}

.floating-module {
            position: fixed;
            right: 10px;
            top: 50%;
            transform: translateY(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            z-index: 999;
        }
        .floating-button {
            width: 50px;
            height: 50px;
            background-color: #ffffff;
            color: white;
            border: none;
            border-radius: 50%;
            margin: 5px 0;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
            transition: background-color 0.3s, transform 0.3s;
        }
        .floating-button:hover {
            background-color: #4095e5;
            transform: scale(1.1);
        }
        .floating-button img {
            width: 50%;
            height: 50%;
        }

</style>
相关推荐
Aric_Jones1 小时前
JavaScript 从入门到精通:完整语法指南
开发语言·javascript·ecmascript
西门吹-禅4 小时前
文本搜索node js--meilisearch
开发语言·javascript·ecmascript
问今域中5 小时前
Vue的computed用法解析
前端·javascript·vue.js
扶苏10026 小时前
详解Vue3的provide和inject
前端·javascript·vue.js
奋斗吧程序媛7 小时前
Vue3初体验(2)
前端·javascript·vue.js
FunW1n8 小时前
tmf.js Hook Shark框架相关疑问归纳总结报告
java·前端·javascript
henry1010108 小时前
Deepseek辅助生成的HTML5网页版抄经典《弟子规》
前端·javascript·css·html·html5
一 乐9 小时前
林业资源管理|基于java + vue林业资源管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·林业资源管理系统
扶苏10029 小时前
深入 Vue 3 computed:原理、实战与避坑指南
前端·javascript·vue.js
高德开放平台10 小时前
高德开放平台JS API插件支持WebMCP:重新定义AI与网页交互的新时代
javascript·人工智能·开发者·高德地图