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>
相关推荐
道不尽世间的沧桑37 分钟前
第17篇:网络请求与Axios集成
开发语言·前端·javascript
bin91534 小时前
DeepSeek 助力 Vue 开发:打造丝滑的复制到剪贴板(Copy to Clipboard)
前端·javascript·vue.js·ecmascript·deepseek
晴空万里藏片云5 小时前
elment Table多级表头固定列后,合计行错位显示问题解决
前端·javascript·vue.js
奶球不是球5 小时前
el-button按钮的loading状态设置
前端·javascript
无责任此方_修行中7 小时前
每周见闻分享:杂谈AI取代程序员
javascript·资讯
学代码的小前端7 小时前
0基础学前端-----CSS DAY13
前端·css
dorabighead8 小时前
JavaScript 高级程序设计 读书笔记(第三章)
开发语言·javascript·ecmascript
engchina10 小时前
@media 的常用场景与示例
css·media
林的快手10 小时前
CSS列表属性
前端·javascript·css·ajax·firefox·html5·safari
bug总结10 小时前
新学一个JavaScript 的 classList API
开发语言·javascript·ecmascript