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

如何在React项目中使用CSS实现圆形内细箭头交互效果

圆形内嵌hover箭头效果实现方案

核心逻辑

该效果通过两组同步的过渡动画实现:hover时文字轻微向左偏移,箭头区域同步添加圆形背景、变为白色、轻微向右偏移,整体动画保持一致的时长和缓动函数即可还原目标效果。

通用CSS代码(无需预处理器,直接复制可用)

/* 箭头链接基础容器 */
.arrow-circle-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 500;
  color: #212121;
  text-decoration: none;
  cursor: pointer;
}

/* 文字、箭头统一过渡设置 */
.arrow-circle-link .link-text,
.arrow-circle-link .link-arrow {
  transition: all 0.3s ease;
}

/* 箭头容器默认样式 */
.arrow-circle-link .link-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  line-height: 1;
  border-radius: 50%;
}

/* hover状态样式 */
.arrow-circle-link:hover .link-text {
  transform: translateX(-2px);
}
.arrow-circle-link:hover .link-arrow {
  background-color: #212121;
  color: #ffffff;
  transform: translateX(2px);
}

JSX调用示例

可复用组件封装

const ArrowCircleLink = ({ 
  href, 
  text, 
  target = "_self",
  className = "" 
}) => {
  return (
    <a 
      href={href} 
      target={target} 
      className={`arrow-circle-link ${className}`}
    >
      <span className="link-text">{text}</span>
      <span className="link-arrow">→</span>
    </a>
  );
};

业务代码调用

// 直接传入链接地址与展示文字即可
function YourPage() {
  return (
    <div>
      <ArrowCircleLink href="/guide" text="查看使用指南" />
      <ArrowCircleLink href="https://xxx.com" text="访问外部站点" target="_blank" />
    </div>
  );
}

自定义调整说明

  • 尺寸调整:修改.arrow-circle-link的font-size属性,即可等比例缩放整个组件,无需单独调整其他参数
  • 配色修改:替换对应位置的color、background-color属性值即可匹配项目设计规范
  • 动画调整:修改transition属性的第一个参数(时长,默认0.3s)即可调整动画快慢,修改缓动函数可改变动画运动曲线

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.02 06:36:03