這組範例聚焦在「滑鼠移入圖示」時的視覺回饋。核心做法是利用 CSS 的 transition 與 animation,讓圖示本身或偽元素在 hover 時產生背景、顏色、旋轉等變化。這類效果不需要 JavaScript,也能讓介面更靈活。

結構可以很簡單:在一個外層容器中放入多個連結元素,每個連結都帶有共同的圖示類別與效果類別。透過修改外層的效果類別,就能切換不同動畫。
以下以效果 6 為例,滑鼠移入時背景變為白色,圖示外圈以線性方式持續旋轉。
.hi-icon-effect-6 .hi-icon {
box-shadow: 0 0 0 4px rgba(255,255,255,1);
transition: background 0.2s, color 0.2s;
}
.no-touch .hi-icon-effect-6 .hi-icon:hover {
background: rgba(255,255,255,1);
color: #64bb5d;
}
.no-touch .hi-icon-effect-6 .hi-icon:hover:before {
animation: spinAround 2s linear infinite;
}
@keyframes spinAround {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
只要熟悉 transition 與 animation,就能理解這段寫法:hover 改變背景與文字顏色,偽元素 :before 負責旋轉。其他效果也能沿用相同概念,替換成不同的 transform、box-shadow 或 opacity 規則。