【问题标题】:Apply CSS to all select2 but not to id contains a letter and vice versa将 CSS 应用于所有 select2 但不应用于 id 包含字母,反之亦然
【发布时间】:2017-07-12 05:52:06
【问题描述】:

我想为所有 id 不包含 month 的 select2 框编写 CSS,我完成了流程。

span[id *= "month"]{
    background-color: red !important;
}

这适用于包含字母。

但以下应该不适用,但它也适用于所有 id 包含 month 的人。

span:not([id *= "month"]){
    background-color: red !important;
}

注意:为什么我使用span标签,因为select会生成带有如下选择标签ID的span标签:

<span title="Month" id="select2-ga_regsmonth-container" class="select2-selection__rendered">Month</span>

我做错了什么? 欣赏

【问题讨论】:

    标签: css jquery-select2


    【解决方案1】:

    似乎工作正常。也许您可以发布您的 HTML?

    span:not([id *="month"]) {
      background-color: red;
    }
    <span id="year">Year</span>
    <span id="month">Month</span>

    【讨论】:

    • Select2 自动生成
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-01
    • 2014-05-12
    • 1970-01-01
    • 1970-01-01
    • 2013-03-25
    • 1970-01-01
    相关资源
    最近更新 更多