三張圖片絕對定位疊在同一位置,透過錨點連結觸發 :target 顯示對應圖片,其餘隱藏。
dl { position: absolute; width: 240px; height: 170px; border: 10px solid #eee; }
dd { margin: 0; width: 240px; height: 170px; overflow: hidden; }
dt { position: absolute; right: 3px; top: 50px; }
dt a { display: block; margin: 1px; width: 20px; height: 20px; line-height: 20px; text-align: center; font: 700 12px/20px "SimSun", sans-serif; color: #fff; text-decoration: none; background: #666; border: 1px solid #fff; opacity: .4; filter: alpha(opacity=40); }
dt a:hover { background: #000; }
/* 關鍵:目標圖片顯示,其他隱藏 */
dd img { position: absolute; top: 0; left: 0; display: none; }
dd img:target { display: block; }
<dl>
<dt>
<a href="#img1">1</a>
<a href="#img2">2</a>
<a href="#img3">3</a>
</dt>
<dd>
<img id="img1" src="1.jpg" alt="">
<img id="img2" src="2.jpg" alt="">
<img id="img3" src="3.jpg" alt="">
</dd>
</dl>
CSS Scroll Snap + 少量 JS 控制自動播放/指示器同步,或採用 Swiper/Glide 等成熟庫。