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

沒有任何類的元素是否有 CSS 選擇器?

Is there a CSS selector for element without any class?(沒有任何類的元素是否有 CSS 選擇器?)
本文介紹了沒有任何類的元素是否有 CSS 選擇器?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

沒有任何類的元素是否有 CSS 選擇器?例如在 HTML 中

Is there a CSS selector for element without any class? For example in HTML

<section>Section A</section>
<section class="special">Section B</section>
<section class="">Section C</section>

我想選擇 A 部分(或者可能是 A 部分和 C 部分,沒那么重要),可以這樣說

I would like to select Section A (or maybe Section A and Section C, it does not matter that much), by saying something like

section:not(.*) { color: gray } 

我知道我可以將其定義為 section 并在所有特定類中重新設置它,例如在

I understand that I could define it to section and reset it back in all particular classes, like in

section { color: gray } 
section.special { color: black } 

但這不是我想要的,因為一旦樣式變得復雜,它就不太容易管理,并且在某些情況下很難正確地重置"(當然不是在這個簡化的示例中).

but this is not what I want, because it is not very manageable once the styles get complex and in some cases it is hard to do the "reset" properly (of course not in this simplified example).

推薦答案

使用 section:not([class]) 您可以選擇沒有 class 屬性的每個部分.不幸的是,它不會選擇具有空類屬性值的那些部分.所以除此之外,我們必須排除這些部分:

With section:not([class]) you select every section without the class attribute. Unfortunately, it won't select those sections with an empty class attribute value. So in addition, we have to exclude these sections:

section:not([class]) { /* every section without class - but won't select Section C */
  color: red;
}

section[class=""] { /* selects only Section C */
  font-weight: bold;
}

<section>Section A</section>
<section class="special">Section B</section>
<section class="">Section C</section>

  • CSS 屬性選擇器, 瀏覽器支持
  • :not

這篇關于沒有任何類的元素是否有 CSS 選擇器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Style every third element?(每隔三個元素設置樣式?)
Why shouldn#39;t I use ID selectors in CSS?(為什么我不應該在 CSS 中使用 ID 選擇器?)
What does img[class*=quot;alignquot;] mean in CSS?(CSS 中的 img[class*=“align] 是什么意思?)
CSS: Last element on line(CSS:最后一個元素)
How do I select every other div class element using just CSS (no js)(如何僅使用 CSS(無 js)選擇所有其他 div 類元素)
Tool for checking unused CSS selectors?(檢查未使用的 CSS 選擇器的工具?)
主站蜘蛛池模板: av在线免费播放 | 日日操网站 | 国产成人99久久亚洲综合精品 | 久久综合888| 狠狠狠色丁香婷婷综合久久五月 | 久久精品影视 | 一级久久久久久 | 一区二区三区四区在线播放 | 男女下面一进一出网站 | 精品久久香蕉国产线看观看亚洲 | 日韩中出| 久久黄视频 | 91精品久久久久久综合五月天 | 精品国产乱码久久久久久蜜退臀 | 成人性生交大片 | 精品伊人久久 | 欧美中文字幕 | 成人影院午夜 | 一区二区三区欧美在线 | 成人av观看 | 久久成人精品视频 | 久久亚洲免费 | 一级毛片色一级 | 日本亚洲欧美 | 国产精品久久国产精品 | 亚洲精品一区在线观看 | 久久久久久久国产精品 | 色偷偷888欧美精品久久久 | 日韩欧美1区2区 | 成人免费视频网站 | 毛片大全 | 爱综合| 国产一级黄色网 | www.xxxx欧美| 欧美在线日韩 | 国产在线精品一区二区 | 国产精品久久久久久久免费大片 | 亚洲人在线观看视频 | 97视频成人 | 精品视频一区二区三区在线观看 | 成人av电影免费在线观看 |