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

CSS:不是偽類不起作用

CSS :not pseudo-class not working(CSS:不是偽類不起作用)
本文介紹了CSS:不是偽類不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在學習 :not() 偽類,但它沒有按預期工作.

我想將除 .mind 之外的所有文本都涂成紅色.出于某種原因,這并不能阻止 .mind 元素變紅.

:not(.mind) {紅色}

<div class='parent'><div class='child'>一個</div><div class='child'>兩個</div><div class='child'>三個</div><div class='child'>一個</div><div class='child'>兩個</div><div class='child'>三個</div><div class='child'>一個</div><div class='mind'>mind</div><div class='child'>三個</div><div 類='孩子'><p>第一段</p></div></div>

解決方案

記住這一點:

:not() 等價于 *:not()

:not() 偽類前面沒有選擇器時,隱含一個通用選擇器:

<塊引用>

測試此行為的快速方法是使用不可繼承的 border 屬性.

在下面的示例中,使用您的選擇器,您會注意到邊框沒有應用到 .mind,并且您的選擇器按預期工作:

:not(.mind) {紅色;邊框底部:1px 虛線黑色;}

<div class='parent'><div class='child'>一個</div><div class='child'>兩個</div><div class='child'>三個</div><div class='child'>一個</div><div class='child'>兩個</div><div class='child'>三個</div><div class='child'>一個</div><div class='mind'>mind</div><div class='child'>三個</div><div 類='孩子'><p>第一段</p></div></div>

為了您的特定目標:

<塊引用>

我想將除 .mind 之外的所有文本都涂成紅色.

使用更具體的選擇器.

.parent >:沒關系) {紅色;}

<div class='parent'><div class='child'>一個</div><div class='child'>兩個</div><div class='child'>三個</div><div class='child'>一個</div><div class='child'>兩個</div><div class='child'>三個</div><div class='child'>一個</div><div class='mind'>mind</div><div class='child'>三個</div><div 類='孩子'><p>第一段</p></div></div>

I am learning about the :not() pseudo class and it is not working as expected.

I want to color all text red except for .mind. For some reason this is not preventing the .mind element from being red.

:not(.mind) {
  color: red
}

<div class='parent'>
  <div class='child'>One</div>
  <div class='child'>Two</div>
  <div class='child'>Three</div>
  <div class='child'>One</div>
  <div class='child'>Two</div>
  <div class='child'>Three</div>
  <div class='child'>One</div>
  <div class='mind'>mind</div>
  <div class='child'>Three</div>
  <div class='child'>
    <p>First paragraph</p>
  </div>
</div>

解決方案

Keep this in mind:

:not() is equivalent to *:not()

When there is no selector prefixing the :not() pseudo-class, a universal selector is implied:

6.2. Universal selector

If a universal selector represented by * (i.e. without a namespace prefix) is not the only component of a sequence of simple selectors selectors or is immediately followed by a pseudo-element, then the * may be omitted and the universal selector's presence implied.

Therefore, the rule you have:

:not(.mind) {
  color: red
}

... is saying apply red color to all elements except the element with the class mind.

Okay, except in this case, the color property is inheritable, so even though the red doesn't get applied to the .mind element, it still gets the red through inheritance from the .parent element.

Here's what the browser is doing:

A quick way to test this behavior is with the border property, which is not inheritable.

In the example below, using your selector, you'll notice that the border doesn't get applied to .mind, and your selector works as you were expecting:

:not(.mind) {
  color: red;
  border-bottom: 1px dashed black;
}

<div class='parent'>
  <div class='child'>One</div>
  <div class='child'>Two</div>
  <div class='child'>Three</div>
  <div class='child'>One</div>
  <div class='child'>Two</div>
  <div class='child'>Three</div>
  <div class='child'>One</div>
  <div class='mind'>mind</div>
  <div class='child'>Three</div>
  <div class='child'>
    <p>First paragraph</p>
  </div>
</div>

To your particular objective:

I want to color all text red except for .mind.

Use a more specific selector.

.parent > :not(.mind) {
  color: red;
}

<div class='parent'>
  <div class='child'>One</div>
  <div class='child'>Two</div>
  <div class='child'>Three</div>
  <div class='child'>One</div>
  <div class='child'>Two</div>
  <div class='child'>Three</div>
  <div class='child'>One</div>
  <div class='mind'>mind</div>
  <div class='child'>Three</div>
  <div class='child'>
    <p>First paragraph</p>
  </div>
</div>

這篇關于CSS:不是偽類不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

CSS selector when :target empty(:target 為空時的 CSS 選擇器)
Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在選擇性方面沒有任何價值嗎?)
Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的結果是否有序?)
Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯誤:當使用 JS 刪除項目時,first-child 不更新 display:block)
nth-Child CSS selectors(nth-子 CSS 選擇器)
Using same ID for multiple HTML tags?(對多個 HTML 標簽使用相同的 ID?)
主站蜘蛛池模板: 在线免费看av | 国产一级片免费看 | av不卡在线 | 伊人色综合网 | 成人av一区 | 精品综合网| 伊人超碰在线 | 亚洲精品一区二区在线观看 | 国产91热爆ts人妖系列 | 国产999视频 | 久在线视频 | 黄色片视频免费 | 无遮挡毛片 | 欧美精品一级片 | 欧美性猛交xxxx | 日韩中文字幕第一页 | 久久久久毛片 | 亚洲在线一区二区 | 欧美激情一区 | 美女福利视频 | 日本一级大毛片a一 | 久久999| 黄色成年 | 国产精品偷乱一区二区三区 | 国产精品成人免费精品自在线观看 | 国产精品久久久久久久免费看 | 中文字幕亚洲一区 | 久久精品福利 | 久久国产精品免费视频 | 国产免费自拍视频 | 黄色一级片视频 | 天天做天天干 | 国产黄色一区 | 国产日本在线观看 | 色婷婷精品国产一区二区三区 | 午夜视频免费 | 欧美一区二区三 | 日韩在线小视频 | 日韩久久久久久久 | 欧美性猛交xxxx乱大交退制版 | av毛片在线播放 |