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

HTML/CSS轮播图:添加角部文本与跳转链接问题

轮播图添加角落文本与点击跳转的实现方案

1. 实现点击跳转效果

将整个轮播容器嵌套在<a>标签中,给<a>设置display: block,使其占据轮播容器的全部空间,确保点击轮播任意区域都能触发跳转。

2. 添加角落文本

借助父容器tech-slideshow的position: relative属性,新增一个绝对定位的文本元素,通过方位属性(如top、right)控制文本位置,并用z-index保证文本显示在轮播图上方。


修改后的完整代码

CSS 代码

.tech-slideshow {
  height: 190px;
  max-width: 2600px;
  margin: 0;
  position: relative;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
}

/* 跳转链接样式 */
.tech-slideshow-link {
  display: block;
  height: 100%;
  width: 100%;
}

.tech-slideshow > div {
  height: 200px;
  width: 2526px;
  background: url(https://resmim.net/cdn/2022/10/22/OybOx.jpg);
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  transform: translate3d(0, 0, 0);
}
.tech-slideshow .mover-1 {
  animation: moveSlideshow 40s linear infinite;
}

/* 角落文本样式 */
.slide-caption {
  position: absolute;
  top: 10px;
  right: 10px;
  color: #fff;
  background-color: rgba(0,0,0,0.5);
  padding: 5px 10px;
  z-index: 10;
  font-size: 14px;
}

@keyframes moveSlideshow {
  50% { 
    transform: translateX(-40%);  
  }
}

HTML 代码

<div class="tech-slideshow">
  <a href="你的跳转链接地址" class="tech-slideshow-link">
    <div class="mover-1"></div>
  </a>
  <div class="slide-caption">这里是角落文本</div>
</div>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 00:05:10