久久久久久久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?)
主站蜘蛛池模板: 欧美aaa| 99久视频| 国产精品久久久久久一区二区三区 | 亚洲毛片在线观看 | 久久草在线视频 | 免费观看羞羞视频网站 | 91中文字幕在线 | 日韩av一区二区在线观看 | 啪啪综合网 | 亚洲成人精品一区二区 | 日本一二三区高清 | 精品一区二区视频 | 国产农村妇女毛片精品久久麻豆 | 成人看片在线观看 | 国产999精品久久久久久绿帽 | 欧美日韩国产一区二区三区 | 夜夜骚| 亚洲精品电影在线观看 | 精品久久久久久久久久 | 围产精品久久久久久久 | 精品久久久久久 | 色眯眯视频在线观看 | 二区视频| 久久免费视频1 | 99久久婷婷国产精品综合 | 日韩欧美在线观看视频 | 日韩在线播放av | 成人欧美一区二区三区黑人孕妇 | 色999日韩| 国产aⅴ爽av久久久久久久 | 3p视频在线观看 | 中文字幕动漫成人 | 成年人在线观看视频 | 国产特级毛片 | 日日夜夜精品视频 | 日韩午夜影院 | 欧美精品在线一区 | 国产精品免费在线 | 中文字幕在线观看精品 | 亚洲精品久久久久久国产精华液 | 亚洲精品久|