且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我可以使用CSS来基于子元素计数应用样式吗?

更新时间:2023-11-09 22:20:40

您可以选择未来选项 t在父级( DIV.items )上指定它,但你可以在子级( DIV.item :only-child 伪类。由于您在这里为子女的后代设计样式,您所要做的事实上是可能的:

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;
}