flukeout / css-diner

CSS Diner
http://cssdiner.com
Mozilla Public License 2.0
2.72k stars 342 forks source link

Task 17 #243

Open Masimakinova opened 1 year ago

Masimakinova commented 1 year ago

Hi! I resolved task number 17 but I don't understand how it worked. Why it didn't picke small orange ? I wrote this: " .small:last child "

MarcusOrhan commented 1 year ago

Hi, If you want to select every -last-child remove the ".small" from your request so : :last-child ==> selects small apple in fancy plate, large last orange in the plate and small last pickle.

Sanjincs commented 1 year ago

@Masimakinova - I thought the same and wondering why is it acceptable.

ricardoanguiano commented 12 months ago

@Masimakinova @Sanjincs Hello, I got stuck reasoning about this answer too, but trying other selectors helped me understand why this works the way it does.

The .small:last-child selector doesn't pick the small orange because the small orange is not the last-child of the parent plate tag. The large orange is the last-child.

You can see this if you choose plate orange:last-child as your selector: the large orange vibrates, not the small orange.

You can also see this if you enter .small:first-child so both the small orange and the small apple are selected, but the small pickle is not selected because while it has class=small, it is the last element of the table, not the first.