You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何围绕浮动操作按钮创建带可点击工具提示的弧形图标组

解决方案

一、改造为弧形环绕布局

通过调整定位与CSS变换,让四个子按钮以主按钮为中心呈弧形排列:

  • 将.adminButtons设置为绝对定位,以主按钮的右下角为变换原点
  • 为每个子按钮设置初始位置,展开时通过rotate与translate组合实现弧形位移
  • 保留原有过渡延迟,维持展开的层次感

二、实现可点击Tooltip

利用CSS伪元素实现悬停提示,同时保证提示区域可点击:

  • 给每个子按钮添加data-tooltip属性存储提示文本
  • 使用:before伪元素创建提示容器,默认隐藏,悬停时显示
  • 添加箭头样式增强提示的指向性,确保提示跟随按钮位置

修改后的完整代码

CSS

body {
  background-color: #f5f5f5;
}

.adminActions {
  position: fixed;
  bottom: 35px;
  right: 35px;
  position: relative;
}

.adminButton {
  height: 60px;
  width: 60px;
  background-color: rgba(67, 83, 143, .8);
  border-radius: 50%;
  display: block;
  color: #fff;
  text-align: center;
  position: relative;
  z-index: 1;
}

.adminButton i {
  font-size: 22px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.adminButtons {
  position: absolute;
  width: 200px;
  height: 200px;
  bottom: 30px;
  right: 30px;
  transform-origin: bottom right;
}

.adminButtons a {
  display: block;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  text-decoration: none;
  color: #fff;
  opacity: 0;
  visibility: hidden;
  position: absolute;
  box-shadow: 0 0 5px 1px rgba(51, 51, 51, .3);
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, 0);
  transition: opacity .2s ease-in-out, transform .3s ease-in-out;
}

.adminButtons a:hover {
  transform: scale(1.05) !important;
}

.adminButtons a:nth-child(1) {
  background-color: #ff5722;
  transition-delay: .3s;
}

.adminButtons a:nth-child(2) {
  background-color: #03a9f4;
  transition-delay: .25s;
}

.adminButtons a:nth-child(3) {
  background-color: #f44336;
  transition-delay: .2s;
}

.adminButtons a:nth-child(4) {
  background-color: #4CAF50;
  transition-delay: .15s;
}

.adminToggle:checked~.adminButtons a:nth-child(1) {
  transform: rotate(-45deg) translate(0, -120px) rotate(45deg);
}

.adminToggle:checked~.adminButtons a:nth-child(2) {
  transform: rotate(-90deg) translate(0, -120px) rotate(90deg);
}

.adminToggle:checked~.adminButtons a:nth-child(3) {
  transform: rotate(-135deg) translate(0, -120px) rotate(135deg);
}

.adminToggle:checked~.adminButtons a:nth-child(4) {
  transform: rotate(-180deg) translate(0, -120px) rotate(180deg);
}

.adminActions a i {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.adminToggle {
  -webkit-appearance: none;
  position: absolute;
  border-radius: 50%;
  top: 0;
  left: 0;
  margin: 0;
  width: 60px;
  height: 60px;
  cursor: pointer;
  background-color: transparent;
  border: none;
  outline: none;
  z-index: 2;
  transition: box-shadow .2s ease-in-out;
  box-shadow: 0 3px 5px 1px rgba(51, 51, 51, .3);
}

.adminToggle:hover {
  box-shadow: 0 3px 6px 2px rgba(51, 51, 51, .3);
}

.adminToggle:checked~.adminButtons a {
  opacity: 1;
  visibility: visible;
}

/* Tooltip样式 */
.adminButtons a[data-tooltip]:hover:before {
  content: attr(data-tooltip);
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  background-color: #333;
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 14px;
  white-space: nowrap;
  margin-right: 8px;
  z-index: 10;
}

/* Tooltip箭头 */
.adminButtons a[data-tooltip]:hover:after {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: #333;
  margin-right: 3px;
}

HTML

<div class="adminActions">
  <input type="checkbox" name="adminToggle" class="adminToggle" />
  <a class="adminButton" href="#!"><i class="fa fa-cog"></i></a>
  <div class="adminButtons">
    <a href="#" data-tooltip="Add Company"><i class="fa fa-building"></i></a>
    <a href="#" data-tooltip="Edit Company"><i class="fa fa-pen"></i></a>
    <a href="#" data-tooltip="Add User"><i class="fa fa-user-plus"></i></a>
    <a href="#" data-tooltip="Edit User"><i class="fa fa-user-edit"></i></a>
  </div>
</div>

内容的提问来源于stack exchange,提问作者tyler

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 04:30:12