我做错了什么?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