新聞網站上五顏六色、錯落有致的熱搜標籤,總能一眼抓住重點。本文示範如何以 jQuery 打造一款仿百度新聞風格的熱搜詞標籤盒子,讓你的關鍵字佈局既吸睛又有條理。
效果展示:
https://hovertree.com/texiao/jquery/66/
源碼下載:
https://hovertree.com/h/bjaf/baidureci.htm
效果圖:
每個標籤都是一個 <li>,透過不同的 class(如 tag1、tag2、tag3)套用相異的背景色,營造出繽紛的視覺層次。標籤內可放置標題、說明文字與突顯的關鍵字:
<div class="hovdertreeBox">
<ul class="artist_l">
<li class="tag1">
<div class="tag_txt">
jQuery彩色手風琴特效適合移動端
</div>
<a href="...">查看詳情</a>
</li>
<li class="tag1 tag2">
<div class="tag_txt">CSS3 3D和2D旋轉翻轉區別</div>
</li>
</ul>
</div>引入 jQuery 與外部腳本後,標籤盒子即可呈現排列與懸停互動。透過 hove 效果,滑鼠移入時標籤會有細微的反應,讓整組關鍵字更靈活:
<script src="https://down.hovertree.com/jquery/jquery-1.4.2.min.js"></script>
<script src="https://hovertree.com/texiao/jquery/66/js/script.js"></script>只要替換文字與連結,這款標籤盒子就能廣泛應用於新聞列表、熱門關鍵字或推薦內容等場景。