只要我有一個規則,如果有3個div,另一個是4個div。如果x元素的Css選擇器目標
標記
//one set of rules
<div></div>
<div></div>
<div></div>
//second fules
<div></div>
<div></div>
<div></div>
<div></div>
CSS
/* three items */
div:nth-child(1):nth-last-child(3),
div:nth-child(2):nth-last-child(2),
div:nth-child(3):nth-last-child(1)
/* fouritems */
div:nth-child(1):nth-last-child(4),
div:nth-child(2):nth-last-child(3),
div:nth-child(3):nth-last-child(2),
div:nth-child(4):nth-last-child(1)
我已經按照這樣的:http://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/但與多少運氣黯然。
那麼,首先,你的第一組選擇器使用'li',而你的第二組選擇器只有'v'。如果這只是一個錯字,你可能想糾正它,再次測試一下,以確保你知道你真的嘗試了一個有效的選擇器,但它仍然無法正常工作。 – BoltClock
還有其他重要的一點,比如這些是唯一的孩子,還是與其他元素混合在一起(向我們顯示您的實際標記),您測試過的瀏覽器等等。 – BoltClock
:)這些都是typeos。 v的意思是'cntrl-v'的確,真正的代碼實際上並沒有使用div的 –