【问题标题】:nth-of-type don't show anything after 2 [duplicate]第n个类型在2之后不显示任何内容[重复]
【发布时间】:2017-02-25 08:27:59
【问题描述】:

我怎么能说只显示第一件事?

.box:nth-of-type(2) {
    display:none;}

只隐藏第二个,怎么说“隐藏除了第一个”?

【问题讨论】:

标签: css


【解决方案1】:

您可以将:not 选择器与:first-child 一起使用。

.box:not(:first-child){display:none;}

您可以使用:first-child 选择器选择第一个元素,并为其赋予display:block; 的属性。并将display:none; 属性添加到其他元素

.box:first-child{display:block;}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多