久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

嵌套在 css :not() 選擇器中

nesting inside css :not() selectors(嵌套在 css :not() 選擇器中)
本文介紹了嵌套在 css :not() 選擇器中的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

是否可以在 :not 選擇器中包含嵌套值?例如:

Is it possible to have nested values inside the :not selector? For eg:

:not(div > div)

每當(dāng)我嘗試它時(shí),它似乎都不起作用.也許您需要以另一種我還沒(méi)有想到的方式使用它?到目前為止,在我看到的所有示例中,您只能在此選擇器中使用一個(gè)值.

Whenever I tried it, it does not seem to work. Perhaps you need to use it another way which I have not figured out? So far, in all the examples I see, you can only use one value inside this selector.

推薦答案

:not() 一次只接受一個(gè)簡(jiǎn)單的選擇器;Selectors 3 規(guī)范中提到了這一點(diǎn):

:not() only accepts one simple selector at a time; this is mentioned in the Selectors 3 spec:

否定偽類 :not(X) 是一個(gè)采用 簡(jiǎn)單選擇器(不包括否定偽類本身)作為參數(shù).它表示其參數(shù)未表示的元素.

The negation pseudo-class, :not(X), is a functional notation taking a simple selector (excluding the negation pseudo-class itself) as an argument. It represents an element that is not represented by its argument.

您的示例中的簡(jiǎn)單選擇器將是您擁有的兩個(gè) div 標(biāo)記.其他簡(jiǎn)單的選擇器包括類選擇器、ID 選擇器、屬性選擇器和偽類.它不接受多個(gè)簡(jiǎn)單的選擇器,也不接受 > 或空格等組合符.

The simple selectors in your example would be the two div tokens that you have. Other simple selectors include class selectors, ID selectors, attribute selectors and pseudo-classes. It does not accept more than one simple selector, nor does it accept combinators like > or space.

根據(jù)您要準(zhǔn)確選擇的元素,可能無(wú)法排除 div >div:

Depending on which elements you're trying to select exactly, there may not be a way to exclude div > div:

  • 如果您只想選擇 div 的子元素,而這些元素本身不是 div,請(qǐng)改用:

  • If you only want to select elements that are children of a div, that are themselves not div, use this instead:

div > :not(div)

  • 如果您只想選擇父元素不是 divdiv 元素,請(qǐng)改用:

  • If you only want to select div elements whose parent element is not a div, use this instead:

    :not(div) > div
    

  • 如果你想單獨(dú)使用這個(gè)否定,選擇所有個(gè)其他元素,那么只使用一個(gè)選擇器是沒(méi)有辦法的.

    If you want to use this negation by itself, selecting all other elements, then there isn't a way using just a selector.

    我能想到的唯一其他可行的 CSS 解決方法是在沒(méi)有 :not() 表達(dá)式的情況下將樣式應(yīng)用于您想要的元素,然后為 div > 撤消它們.div.這適用于您嘗試定位的任何一組元素;缺點(diǎn)是并非所有屬性都可以輕松重置.

    The only other viable workaround in CSS that I can think of is to apply styles to the elements you want without the :not() expression, then undo them for div > div. This works for any set of elements you're trying to target; the disadvantage is that not all properties can be easily reset.

    或者,如果您使用 jQuery,它確實(shí)支持 :not(div > div) 與 CSS 版本不同,您可以將選擇器放在腳本中,例如,讓 jQuery 將類名應(yīng)用于那些然后元素在您的 CSS 中定位該類.

    Alternatively, if you're using jQuery, which does support :not(div > div) unlike the CSS version, you can place the selector in a script and, for instance, have jQuery apply a class name to those elements then target that class in your CSS.

    這篇關(guān)于嵌套在 css :not() 選擇器中的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

    【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

    相關(guān)文檔推薦

    CSS selector when :target empty(:target 為空時(shí)的 CSS 選擇器)
    Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在選擇性方面沒(méi)有任何價(jià)值嗎?)
    Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的結(jié)果是否有序?)
    Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯(cuò)誤:當(dāng)使用 JS 刪除項(xiàng)目時(shí),first-child 不更新 display:block)
    nth-Child CSS selectors(nth-子 CSS 選擇器)
    Using same ID for multiple HTML tags?(對(duì)多個(gè) HTML 標(biāo)簽使用相同的 ID?)
    主站蜘蛛池模板: 午夜视频免费看 | 国产精品美女在线观看 | 欧美日韩啪啪 | 一级片在线播放 | 97精品国产露脸对白 | 欧美精品999 | 亚洲黄色成人 | 99黄色| 99这里只有精品 | 伊人成人在线 | 国产精品国产三级国产 | 久草视频免费在线观看 | 日韩av免费在线播放 | 国产日韩欧美亚洲 | 久久久精品免费 | 黄色片免费看 | 久久精品在线观看 | www.青青草 | 亚洲精品一区二区三区精华液 | 成人在线视频网站 | 日本少妇久久 | 日韩网站免费观看 | 免费看v片 | 欧美成人小视频 | 中文字幕在线观看日本 | 91手机看片| www.精品国产| 国产精品suv一区二区 | 国产精品一品二区三区的使用体验 | 伊人操| 亚洲一区二区av | 国产人人干 | 丁香婷婷在线 | 欧美成人激情视频 | 中文字幕在线视频观看 | 久久精品一区二区三区不卡牛牛 | 日韩在线一区二区三区 | 激情久久综合 | 99视频网| 亚洲精品黄 | 日韩精品一区在线 |