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

效果图:

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

html 复制代码
<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>
html 复制代码
<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项目的顶层路由文件中添加即可。

相关推荐
PFinal社区_南丞1 天前
现代CSS开发环境搭建
css
Keepreal4961 天前
pdf文件预览实现
javascript·react.js
IT_陈寒1 天前
Python性能优化:用这5个鲜为人知的内置函数让你的代码提速50%
前端·人工智能·后端
PFinal社区_南丞1 天前
容器查询 - 组件级响应式设计
css
简小瑞1 天前
VSCode源码解密:一行代码解决内存泄漏难题
前端·设计模式·visual studio code
邢行行1 天前
Node.js 核心模块与模块化笔记
前端
Asort1 天前
JavaScript设计模式(九)——装饰器模式 (Decorator)
前端·javascript·设计模式
Man1 天前
🔥 Vue3 动态 ref 黑科技:一招解决 v-for 中的组件引用难题!
前端·vue.js
叫我少年1 天前
Vue3 集成 VueRouter
vue.js
披萨心肠1 天前
Vue单向数据流下双向绑定父子组件数据
vue.js