我做錯了什麼?pseudoclass:第一個孩子不工作
CSS /頂嘴:
#section
article
border-top: 1px solid black
&:first-child
border: none !important
HTML/HAML:
#section
%h2 title
%article
stuff here. There is still a top border here despite first-child style.
%article
stuff here.
%article
stuff here.
這不起作用,而且還有第一<article>
邊框。我必須在第一篇文章中創建另一個課程並執行諸如article.noborder
之類的操作,以獲得無邊框。任何幫助將不勝感激... CSS恨我。
你做錯的事是誤解':first-child'。 'article:first-child'並不意味着「匹配第一個'article'元素」,這意味着「匹配第一個孩子**如果**它是一個'article'元素」 - 在這種情況下,第一個孩子是' h2'。 – thirtydot