DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> CSS進階教程
CSS+DIV 網頁特效:超酷的四角 BANNER
編輯:CSS進階教程     

想為網頁的四個角落加上別致的裝飾性 BANNER 嗎?透過絕對定位把圖片釘在視窗的四角,再用 text-indent 把文字推離視線,就能做出乾淨俐落的角標效果。以下提供右上與左上兩個範例。

右上角 BANNER

#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;
}

左上角 BANNER

#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 換成自己的圖檔,輕鬆為網站加上個性化的角標裝飾。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved