issues
search
hsiaofung
/
note
0
stars
0
forks
source link
2020-8-10 CSS大全
#166
Open
hsiaofung
opened
4 years ago
hsiaofung
commented
4 years ago
CSS與文件
元素是文件結構的基礎
元素有兩類 : 置換元素與非置換元素
置換元素 : 元素的內容會被置換成某些文章內容外的東西。例如 : img
非置換元素 : 瀏覽器會直接以元素本身產生元素的內容。呈現在某個方框當中。文字、段落、標題、表格欄位、列表等幾乎所有HTML元素都是如此。
元素顯示角色 :
區塊級 : 會產生一個填滿父元素內容區塊且無法與其他元素並排的元素方框,也就會在元素方框的前後產生斷行,例如 : p與div。置換元素雖然可以是區塊元素,但通常不是。
行內級: 可以出現在其他元素的內容裡,不會在前後產生斷行。
HTML標記的區塊元素和行內元素,不允許相反方向。
但是在CSS就沒有這樣的限制。可以讓標記維持原樣,透過display改變兩個元素的顯示角色。可以在行內方框中產生一個區塊方框,完全符合語法,不違反任何的CSS規範。但要是改變HTML中元素的巢狀結構,就會發生問題。
能夠改變顯示角色的能力讓CSS在許多情況下都非常好用。
建立CSS與文件關聯的方法 : 連結CSS與HTML
link 標記 : 使用link建立目前文件與另一份文件的關聯。
link 標記必須放在head元素內。
@import : 也可在
CSS與文件
元素是文件結構的基礎
元素有兩類 : 置換元素與非置換元素
元素顯示角色 :
建立CSS與文件關聯的方法 : 連結CSS與HTML