css

加js, css file 到theme, Add a theme specific js/css to a page

如題, 你可以在 theme 的 .info file 用以下的方法

scripts[] = js/gallery.js

stylesheets[all][] = css/gallery.css

你可以加第三方的 js/css, 例如 jquery ui, fancybox 之類
如果你看到你的page.tpl.php 有<script type="text/javascript" src=""></script>你可能會考慮用以上的方法include 了

Note1: 路徑是相對到theme 的資料夾
Node2: 它們會被優化的, 如果你開啟了壓縮 js/css 檔案的話

As titled, if you want to add a js or css file only to a theme, you may:

scripts[] = js/gallery.js

stylesheets[all][] = css/gallery.css

This should contain mostly contain some 3rd party js/css libraries/frameworks.
if you find you put some <script type="text/javascript" src=""></script> in page.tpl.php, you better think again to put it like above.

Note1: the path they refered is CURRENT_THEME directory
Node2: They will got aggregated if you turn on compressing js/css files in "Performance" page

print.css

Drupal 內的一個常用的theme, Garland
經常給我用作範本, 東改改西改改成為一個新的theme
因為他左右sidebar 都可以, header, template.php 變數都很齊備
這次簡單說明一下theme 內的print.css >Read more

CSS 的規則繼承和權重

路過 CSS specificity for poker players
這篇關於CSS 承繼規則的確不錯
CSS 是一種承繼的語言, 一個<a> 可以同時承繼兩個style
比如

a{color:#000;}
p a{color:#f00;}

那究竟瀏覽器要如何決定一個<a> 的顏色?
就是這一篇所述的內容了 >Read more