css筆記(就是書中的一些摘抄^_^)

divs should be used to group related items based on their meaning or
function rather than their presentation or layout.

Whereas divs can be used to group block-level elements, spans can be used to group or
identify inline elements:
div只是一個分塊的標籤,他可以將網頁分成幾個區塊。div裏面可能包含一個標題,一個段落,也可能包含圖片在內的很多元素,甚至div也可以再包含div。而span是行級元素(行內標籤),通常情況下它都用來定義一小段文字的樣式。它們的另一個區別就是div會造成換行,而span則不會。

Unfortunately, IE 6
automatically switches to quirks mode if the DOCTYPE declaration is not the first element
on a page. Therefore, unless you are serving your pages as XML documents, it is best to
avoid using an XML declaration

The most common kinds of selectors are type and descendant selectors

可以用id指定某一個元素,用class指定某一類元素

ID selectors are identified using a hash character; class selectors are identified
with a period.

:link and :visited are known as link pseudo-classes and can only be applied to anchor
elements. :hover, :active, and :focus are known as dynamic pseudo-classes and can
theoretically be applied to any element.

Child and adjacent sibling selectors
Attribute selectors

a rule written in a style
attribute will always be more specific than any other rule. A rule with an ID will be more
specific than one without an ID, and a rule with a class selector will be more specific than
a rule with just type selectors. Finally, if two rules have the same specificity, the last one defined prevails.

--------------------------------------------------------------------------------------------
Every element on the page is
considered to be a rectangular box made up of the element’s content, padding, border,
and margin

Margin collapsing  
Margin collapsing only happens with the vertical margins of block boxes in the normal
flow of the document. Margins between inline boxes, floated, or absolutely positioned
boxes never collapse.

There are three basic positioning schemes in CSS: normal flow, floats, and absolute positioning.

Block-level boxes will appear vertically one after the other; the vertical distance between
boxes is calculated by the boxes’ vertical margins.Inline boxes are laid out in a line horizontally.

An absolutely positioned element is positioned in relation to its nearest positioned ancestor.

Gradients
Tiling images

在css中,任何東西都可用看成一個element

以div爲例,它的大小默認和content area的相同,如果設置了padding等的話,content的大小不變,但是div的大小會增加。

Image Replacement
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章