4. Grouping and Nesting Selectors
Grouping Selectors:
使用,將多個selectors 合在一起,用於表達相同
的樣式
p , a { color: blue;}
Nesting Selectors:
使用空白將階層性的selectors合在一起,用於表
達HTML Element巢狀結構的樣式
.marked
class
p a {color: green;}
為 marked ,且內容包含 p element,且p
element 中包含 element a 的樣式字型顏色為綠
色
5. Display
Display : none
Inline
block
Visibility : hidden
visible
Different :
Visibility: 即使隱藏了但是仍占版面空間
Display: 隱藏了之後不佔版面空間
Display Note:
Changing the display type of an element changes only how the element is displayed, NOT what kind of
element it is. For example: An inline element set to display:block is not allowed to have a block element
nested inside of it.
9. Navigation Bar
Navigation Bar = List of Links
使用無序列表在li中加入a的element
使用 list-style-type : none; 將圖示移除
將margin、padding設為0
垂直 Navigation Bar
設定Block 讓區塊都可以click
設定a { display : block; width: 60px }
設定width 可點及的範圍
水平Navigation Bar
設定li{ float :left;} a{ display: block; width: 60px; }
設定float讓每一個li比鄰排列
10. Attribute Selectors
[Attribute] 套用所有擁有attribute的element
a[Attribute] 只套用所有擁有attribute的a
[Attribute=value] 套用所有擁有attribute的值為value
[title~=value] :
~= 使用空格分隔比對,區分大小寫
Title = “Value”
Title=“value 123”
Title=“value123”
X
O
X
[lang|=value]
|= 使用-連接值,區分大小寫
Lang = “value”
Lang = “value-us”
Lang = “-value”
O
O
X