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

偽類和偽元素有什么區(qū)別?

What is the difference between pseudo-classes and pseudo-elements?(偽類和偽元素有什么區(qū)別?)
本文介紹了偽類和偽元素有什么區(qū)別?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

div::after {}div:after {} 有什么區(qū)別?我們什么時(shí)候必須使用 :: 而不是 :?

What is the difference between div::after {} and div:after {} ? When do we have to use :: over :?

雙冒號和單冒號是為了區(qū)分偽類和偽元素.

Double colon and single-colon notation is to distinguish between pseudo-classes and pseudo-elements.

上述語句的實(shí)際含義是什么?

What is the actual meaning of the above statement?

推薦答案

來自 https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Pseudo-classes_and_pseudo-elements

偽類:

CSS 偽類是一個(gè)關(guān)鍵字,前面有一個(gè)冒號 (:),添加到選擇器的末尾以指定您要設(shè)置所選元素的樣式,并且 僅當(dāng)它們處于特定狀態(tài)時(shí).例如,您可能希望僅在鼠標(biāo)指針懸停時(shí)設(shè)置元素的樣式,或者在禁用或選中復(fù)選框時(shí)設(shè)置樣式,或者在 DOM 樹中作為其父元素的第一個(gè)子元素.

A CSS pseudo-class is a keyword, preceded by a colon (:), added to the end of selectors to specify you want to style the selected elements, and only when they are in certain state. For example, you might want to style an element only when it is being hovered over by the mouse pointer, or a checkbox when it is disabled or checked, or an element that is the first child of its parent in the DOM tree.

例子:

  • :活躍
  • :勾選
  • :nth-child()
  • :第一
  • :懸停

偽元素 ::

偽元素與偽類非常相似,但它們有區(qū)別.它們是關(guān)鍵字,這一次前面有兩個(gè)冒號 (::),可以添加到選擇器的末尾以選擇元素的某個(gè)部分.

Pseudo-elements are very much like pseudo-classes, but they have differences. They are keywords, this time preceded by two colons (::), that can be added to the end of selectors to select a certain part of an element.

例子:

  • ::之后
  • ::之前
  • ::首字母
  • ::一線
  • ::選擇
  • ::背景

正如@stephanmg 所說:

As stated by @stephanmg:

在實(shí)踐中 ::before 用作 :before 和 ::after 用作 :after因?yàn)闉g覽器兼容性.兩者都是偽元素,但可能看起來像偽類.如果您閱讀 CSS,這可能會令人困惑代碼.

In practice ::before is used as :before and ::after is used as :after because of browser compatibility. Both are pseudo-elements, but may look like pseudo classes. This might be confusing if you read CSS code.

這篇關(guān)于偽類和偽元素有什么區(qū)別?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Style every third element?(每隔三個(gè)元素設(shè)置樣式?)
Why shouldn#39;t I use ID selectors in CSS?(為什么我不應(yīng)該在 CSS 中使用 ID 選擇器?)
What does img[class*=quot;alignquot;] mean in CSS?(CSS 中的 img[class*=“align] 是什么意思?)
CSS: Last element on line(CSS:最后一個(gè)元素)
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在线| 免费啪视频 | 超碰成人av | 97精品超碰一区二区三区 | www.黄色片 | 国产免费久久 | 国产深夜福利 | 国产一级二级 | 91女人18毛片水多国产 | 成人动漫免费观看 | 岛国在线视频 | 日韩久久网 | 亚洲视频在线免费观看 | 日本黄色录像 | www.黄色片 | aaa级片| 亚洲精品久久久久久久久 | 国产1级片 | 亚洲一区久久 | 天堂91 | 97精品超碰一区二区三区 | 欧美午夜精品久久久久免费视 | 国产伦精品一区二区三区视频网站 | 青娱乐福利视频 | a级片免费在线观看 | 国产乱码久久久久久 | av九九| 亚洲伦理视频 | 亚洲乱码在线 | 国产一区二区视频在线播放 | 国产精品av一区二区 | 亚洲欧美国产精品 | 免费看黄色小视频 | 天堂网av在线 | 亚洲精品免费在线 | 国产精品999999 | 亚洲精品tv | 欧美一级色 | 一区二区三区av | 亚洲精品成a人在线观看 | 成人免费视频网址 |