DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> HTML基礎知識 >> HTML和Xhtml
網頁設計參考:Firefox 的預設樣式表
編輯:HTML和Xhtml     

W3C 制訂了 HTML 標準,但各瀏覽器仍會按自己預先定義的樣式來解析與渲染標籤。Firefox 的好處是,你在網址列輸入下面這行就能直接看到它的預設樣式表:

resource://gre/res/html.css

如果 IE 也有同樣的指令就好了。你也可以在不同版本的 Firefox 裡各跑一次,對比版本間的差異——這在撰寫 CSS Reset 時是重要的判斷依據。

雙向文字與區塊

[dir="rtl"] { direction: rtl; unicode-bidi: embed; }
[dir="ltr"] { direction: ltr; unicode-bidi: embed; }
bdo[dir] { unicode-bidi: bidi-override; }

html, div, map, dt, isindex, form { display: block; }
body { display: block; margin: 8px; }

p, dl, multicol { display: block; margin: 1em 0; }
dd { display: block; -moz-margin-start: 40px; }
blockquote { display: block; margin: 1em 40px; }
address { display: block; font-style: italic; }
center { display: block; text-align: -moz-center; }

pre, xmp, plaintext, listing {
  display: block;
  font-family: -moz-fixed;
  white-space: pre;
  margin: 1em 0;
}

標題

h1 { display: block; font-size: 2em;    font-weight: bold; margin: .67em 0; }
h2 { display: block; font-size: 1.5em;  font-weight: bold; margin: .83em 0; }
h3 { display: block; font-size: 1.17em; font-weight: bold; margin: 1em 0; }
h4 { display: block; font-weight: bold; margin: 1.33em 0; }
h5 { display: block; font-size: 0.83em; font-weight: bold; margin: 1.67em 0; }
h6 { display: block; font-size: 0.67em; font-weight: bold; margin: 2.33em 0; }

把這一段和 IE6 的對照值擺在一起看,差異一目了然:h1 在 Firefox 是 2em / .67em,在 IE6 是 2em / .6em;h3 在 Firefox 是 1.17em,在 IE6 是 1.1em。這正是為什麼跨瀏覽器排版一定要做 Reset。

表格

table {
  display: table;
  border-spacing: 2px;
  border-collapse: separate;
  text-indent: 0;
}
caption { display: table-caption; text-align: center; }
tr      { display: table-row; vertical-align: inherit; }
col     { display: table-column; }
colgroup{ display: table-column-group; }
thead   { display: table-header-group; vertical-align: middle; }
tbody   { display: table-row-group; vertical-align: middle; }
tfoot   { display: table-footer-group; vertical-align: middle; }
td, th  { display: table-cell; vertical-align: inherit; text-align: inherit; padding: 1px; }
th      { font-weight: bold; }

行內元素

q:before { content: open-quote; }
q:after  { content: close-quote; }

b, strong { font-weight: bolder; }
i, cite, em, var, dfn { font-style: italic; }
tt, code, kbd, samp { font-family: -moz-fixed; }

u, ins { text-decoration: underline; }
s, strike, del { text-decoration: line-through; }
blink { text-decoration: blink; }

big   { font-size: larger; }
small { font-size: smaller; }

sub { vertical-align: sub;   font-size: smaller; line-height: normal; }
sup { vertical-align: super; font-size: smaller; line-height: normal; }
nobr { white-space: nowrap; }

abbr[title], acronym[title] { border-bottom: dotted 1px; }

清單

ul, menu, dir { display: block; list-style-type: disc; margin: 1em 0; -moz-padding-start: 40px; }
ol { display: block; list-style-type: decimal; margin: 1em 0; -moz-padding-start: 40px; }
li { display: list-item; }

Firefox 有一個很值得學的設計:巢狀清單的外上下邊距會被移除,第二層改用 circle,第三層起改用 square。這讓多層清單的節奏自然收斂,不必自己再覆寫。

其他常用元素

hr { display: block; height: 2px; border: 1px inset; margin: 0.5em auto; color: gray; }
iframe { border: 2px inset; }
frameset { display: block !important; position: static !important; border: none !important; }
frame { border: none !important; }
noframes { display: none; }
canvas { -moz-user-select: none; }

area, base, basefont, head, meta, script, style, title, noembed, param { display: none; }

焦點外框與列印

凡是 tabindex 數值大於或等於 0 的元素都屬於可聚焦內容,Firefox 會給它 1px 的虛線外框(顏色固定使用初始值,不另外指定)。另外,在 @media print 中,跑馬燈的綁定會被取消,blink 的裝飾線也會被拿掉——列印時不該有任何閃爍或移動的東西。

把這份清單當成對照表:當你發現某個元素「莫名其妙」多了外距、多了邊框,或者行高跟你想的不一樣,回來查一下預設值,通常答案就在這裡。

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