Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

bento:nth-last-child(4) worked for me.

It selects the <bento> element that is the 4th child from last.

I think the confusion is here: people think that bento:nth-last-child(2) will be the solution because it should select the second-from-last bento element, but what it does is it selects all bento elements which are the 2nd from last children -- and since in the puzzle there is no bento that is second from last, it selects nothing.

So you have to consider it's siblings. The one we want ot select is the 4th-from-last among its siblings.



That makes very little sense.

Adding the bento: should have removed all the other items from selection.

It sounds like you are explaining a selector such as *:nth-last-child(4)


it in fact works the way that 'makes very little sense'.

There is a good reason, though, and it's in keeping with the 'nth-of-type' selector logic: there is a selector that works the way you think, called nth-last-of-type[0]

[0] http://www.w3schools.com/cssref/sel_nth-last-of-type.asp

[sample page I made just for you on my github.io page] http://flanneljesus.github.io/


i haven't tested it in actual html/css. I'll do that now. I'll get back to you with my results




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: