You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何选择特定类前缀的元素同时排除其他类前缀?

需求与CSS解决方案

需求:选中所有带有以post-type-开头的class的<body>元素,但当该元素同时带有以taxonomy-开头的class时,不选中它。

最初尝试的CSS代码(不可行)

body[class^="post-type-"],
body[class*=" post-type-"] {
    &:not([class^="taxonomy-"]),
    &:not([class*=" taxonomy-"]) {
        .widefat {
            .check-column {
                display: none;
            }
        }
    }
}

调整后可行的CSS代码

body[class^="post-type-"]:not([class^="taxonomy-"]):not([class*=" taxonomy-"]),
body[class*=" post-type-"]:not([class^="taxonomy-"]):not([class*=" taxonomy-"]) {
    .widefat {
        .check-column {
            display: none;
        }
    }
}

内容的提问来源于stack exchange,提问作者Gavin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 05:25:37