【vue】在页面右下角添加悬浮按钮组件

效果图:

如上图所示,需要在页面的左下角添加一个悬浮按钮,鼠标放上去时候展示更多详细按钮,点击触发相应方法。

复制代码
<div class="floating-component">
    <!-- 悬浮内容 -->
    <el-tooltip placement="left" effect="light" popper-class="too">
      <div slot="content">
        <el-button icon="el-icon-s-comment" class="butto" @click="handleQuestion">问题反馈 </el-button>
        <br/>
        <el-button icon="el-icon-question" class="butto" @click="handleHelp">帮助手册 </el-button>
      </div>
      <el-button icon="el-icon-menu" circle class="but"></el-button>
    </el-tooltip>
</div>

<style scoped>
.floating-component {
  position: fixed; /* 固定位置 */
  bottom: 5%; /* 下边距 */
  right: 1%; /* 右边距 */
  padding: 0;
  border-radius: 50%; /* 圆角 */
  z-index: 10000; /* 设置 z-index 确保悬浮在顶层 */
}
.but {
  font-size: larger;
  color: rgb(0,119,216);
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2); /* 阴影 */
}
.butto {
  border: 0;
  padding: 10px;
  margin: 0;
}
</style>

<style>
.too.el-tooltip__popper.is-light {
  border: none !important;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
  padding: 5px
}
/* 修改箭头边框 这里方位是left,所以 x-placement^="left" 并且是设置 border-right-color 的颜色*/
.too.el-tooltip__popper.is-light[x-placement^="left"] .popper__arrow {
  border-left-color: #eaeaea !important;
}
.too.el-tooltip__popper[x-placement^="left"] .popper__arrow {
  border-left-color: #eaeaea !important;
}
</style>

如果需要在所有页面上层展示,在vue项目的顶层路由文件中添加即可。

相关推荐
RaidenLiu4 分钟前
Flutter Platform Channel 底层架构解析 —— 从 BinaryMessenger 到跨平台消息通信机制
前端·flutter·前端框架
bluceli6 分钟前
CSS容器查询:响应式设计的新范式
前端·css
Tapir9 分钟前
被 Karpathy 下场推荐的 NanoClaw 是什么来头
前端·后端·github
前端人类学10 分钟前
深入解析JavaScript中的null与undefined:区别、用法及判断技巧
前端·javascript
ssshooter1 小时前
Tauri 项目实践:客户端与 Web 端的授权登录实现方案
前端·后端·rust
兆子龙1 小时前
【React】19 深度解析:掌握新一代 React 特性
前端·架构
Moment2 小时前
MinIO已死,MinIO万岁
前端·后端·github
无双_Joney2 小时前
心路散文 - 转职遇到AI浪潮,AIGC时刻人的价值是什么?
前端·后端·架构
有意义2 小时前
深度拆解分割等和子集:一维DP数组与倒序遍历的本质
前端·算法·面试
卤蛋fg62 小时前
vxe-table 如何实现分组列头折叠列功能
vue.js