Reputation: 53129
I have a situation where n elements can be present and any can be deleted. But at the point where only one element is present, the deletion should be disabled (ideally by setting display:none
):
And only one item:
My question is if I can do something like this:
DIV.items:ONLY_ONE_CHILD DIV.item BUTTON.delete {
display:none;
}
No is an acceptable answer but in that case I'd like to know about the closest possibility or potentional future options.
Upvotes: 1
Views: 1448
Reputation: 723538
You can't specify it on the parent (DIV.items
), but you can on the child (DIV.item
) with the :only-child
pseudo-class. Since you're styling a descendant of the child here, what you're looking to do is in fact possible:
DIV.item:only-child BUTTON.delete {
display: none;
}
Upvotes: 1