下午好球員,:nth-last-child(-n + 3)不適用於文章元素?
,因爲它說,我想知道爲什麼:nth-last-child(-n+3) {}
我的文檔標記裏面的物品元素是不工作的稱號?根據評論它應該工作,如下面的例子:http://jsfiddle.net/8PXXm/
當我通過我的佈局內的標記,它不適合我。 我想選擇連續的最後3個項目。
.post-entry:nth-last-child(n+3) { display: none; }
上面代碼中選擇所有的行項目,而不是最後3
HTML:
<article class="grid_4 post-entry">
<a href="#" title="">
<figure class="post-thumb">
<img src="../images/placehold.png" alt="Placehold">
<figcaption>
<img src="../images/cross.png" alt="Cross x">
</figcaption><!-- End figcaption.post-thumb -->
</figure><!-- End figure.post-thumb -->
</a>
</article><!-- End article.grid_4 post-entry -->
的jsfiddle:http://jsfiddle.net/4XP5W/11/
希望你能幫助我。 謝謝!
什麼是您的HTML看起來像兄弟姐妹? –
'是否:nth-last-child(-n + 3)與article元素一起工作?' - 是的(參見[** jsfiddle **](http://jsfiddle.net/8PXXm/))。正如你可以在[** w3org Spec on nnth-last-child **](http://www.w3.org/TR/css3-selectors/#nth-last-child-pseudo)中看到的那樣,它沒有提到「article」元素被排除在功能之外。您的問題很可能是CSS命令本身與您擁有的標記結合使用。如果您發佈相關標記,我們可以看看。 – Nope