Computer: Makeuper: CSS: Ex02

From TestingMediawiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

回到 Computer ‧ 回到 Computer: Makeuper ‧ 回到 Computer: Makeuper: CSS


在文件中書寫可以讓有支援多樣式表選擇功能(是叫 Multi-StyleSheet-Selection 嗎????)的瀏覽器可以去選擇不同樣式表的語法。

如 Mozilla 的選項就位於「檢視 V) → 使用其它CSS樣式表 U)」之中。Firefox的則是狀態列左下的小圖示,要在有碰上這種網頁時才會跳出來。

另外也可以試試看用 Javascript 來切換樣式表。如 CyberJos的網頁就是。


重點在於 link tag ,就是在 <HEAD> 引入 *.CSS 檔案的那一行標籤。

<link rel="stylesheet" type="text/css" href="default.css" title="default" >

rel 代表 relation ,在這邊就是 stylesheet 。
type 應該不需要解釋了。
href 當然是你的 CSS URL 位置。
title 就是幫它取個名稱,在選擇時才能方便辯識。

當有兩個以上時,第二個之後的 relation 要從 stylesheet 改為 alternate stylesheet

<link rel="alternate stylesheet" type="text/css" href="second.css" title="second" >


從這邊的例子來看,當別人選 default 就是用第一個 CSS ,選 second 就是第二個 CSS ,差不多就這樣。

不過不是所有的瀏覽器都有這個功能,沒有這個功能的會以 relation 宣告為 stylesheet 為準。


其它相關的資料

http://css-discuss.incutio.com/?page=StyleSwitching