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>
相关推荐
小高0071 分钟前
📈前端图片压缩实战:体积直降 80%,LCP 提升 2 倍
前端·javascript·面试
BillKu13 分钟前
vue3+element-plus 输入框el-input设置背景颜色和字体颜色,样式效果等同于不可编辑的效果
前端·javascript·vue.js
每天学习一丢丢14 分钟前
Spring Boot + Vue 项目用宝塔面板部署指南
vue.js·spring boot·后端
springfe010123 分钟前
vue3组件 - 大文件上传
前端·vue.js
NeilNiu42 分钟前
开源AI工具Midscene.js
javascript·人工智能·开源
好好好明天会更好1 小时前
uniapp项目中小程序的生命周期
前端·vue.js
CF14年老兵1 小时前
「Vue 3 + View Transition 实现炫酷圆形缩放换肤动画」
前端·css·trae
Warren981 小时前
软件测试-Selenium学习笔记
java·javascript·笔记·学习·selenium·测试工具·安全
前端小书童1 小时前
前端开发中的css:「ink → Bootstrap → 预处理器 → Tailwind → UnoCSS」
前端·css
萌萌哒草头将军1 小时前
有了它 ,我彻底告别了 try-finally 🔥🔥🔥
前端·javascript·vue.js