滑鼠懸停時,頁碼按鈕放大、字體加粗、邊框變色、背景變灰,並向左右擴展,形成「凸出」視覺反饋。
.demo a {
float: left;
margin: 5px 1px 0;
width: 20px; height: 20px;
line-height: 20px; text-align: center;
font: 12px/20px "SimSun"; color: #999;
text-decoration: none;
border: 1px solid orange;
transition: all 0.15s ease;
}
.demo a:hover {
position: relative;
margin: 0 -9px; /* 向左右擴展 9px,避免擠壓鄰項 */
padding: 0 5px;
width: 30px; height: 30px;
line-height: 30px;
font: bold 16px/30px "SimSun";
color: #000;
border: 1px solid #000;
background: #eee;
z-index: 1; /* 確保放大層級覆蓋鄰項 */
}
<div class="demo">
<a href="#">1</a><a href="#">2</a><a href="#">3</a><a href="#">4</a><a href="#">5</a>
<a href="#">6</a><a href="#">7</a><a href="#">8</a><a href="#">9</a><a href="#">10</a>
</div>
margin: 0 -9px 配合 padding: 0 5px:視覺寬度從 20px 變 30px,但佔據流體空間不變,避免鄰項跳動。position: relative; z-index: 1:放大時浮於鄰項上方。transition:平滑過渡,提升體驗。