想為網頁的四個角落加上別致的裝飾性 BANNER 嗎?透過絕對定位把圖片釘在視窗的四角,再用 text-indent 把文字推離視線,就能做出乾淨俐落的角標效果。以下提供右上與左上兩個範例。
#topright {
position: absolute;
right: 0;
top: 0;
display: block;
height: 125px;
width: 125px;
background: url(TRbanner.gif) no-repeat;
text-indent: -999em;
text-decoration: none;
}#topleft {
position: absolute;
left: 0;
top: 0;
display: block;
height: 125px;
width: 125px;
background: url(TLbanner.gif) no-repeat;
text-indent: -999em;
text-decoration: none;
}關鍵技巧在於 text-indent: -999em。它把元素內的文字往左推到畫面外,達到「用背景圖取代文字」的效果,同時保留文字在 HTML 中的語意,對搜尋引擎與無障礙閱讀仍友善。搭配 position: absolute 與 top/left/right 定位,就能把 BANNER 精準固定在角落。你可以把 TRbanner.gif、TLbanner.gif 換成自己的圖檔,輕鬆為網站加上個性化的角標裝飾。