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

偽類和偽元素有什么區別?

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

問題描述

div::after {}div:after {} 有什么區別?我們什么時候必須使用 :: 而不是 :?

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

雙冒號和單冒號是為了區分偽類和偽元素.

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

上述語句的實際含義是什么?

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 偽類是一個關鍵字,前面有一個冒號 (:),添加到選擇器的末尾以指定您要設置所選元素的樣式,并且 僅當它們處于特定狀態時.例如,您可能希望僅在鼠標指針懸停時設置元素的樣式,或者在禁用或選中復選框時設置樣式,或者在 DOM 樹中作為其父元素的第一個子元素.

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()
  • :第一
  • :懸停

偽元素 ::

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

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:

在實踐中 ::before 用作 :before 和 ::after 用作 :after因為瀏覽器兼容性.兩者都是偽元素,但可能看起來像偽類.如果您閱讀 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.

這篇關于偽類和偽元素有什么區別?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 選擇器的工具?)
主站蜘蛛池模板: 91麻豆精品一区二区三区 | 欧美日韩国产在线观看 | 人人草人人干 | 99精品热视频 | av中文字幕在线播放 | 91精品麻豆日日躁夜夜躁 | 中文字幕一区二区三区在线观看 | 日本免费视频 | 久久精品国产免费看久久精品 | 国产一级一级毛片 | 超碰97人人人人人蜜桃 | 色视频成人在线观看免 | 玖玖综合网 | 在线观看不卡av | 国产综合网站 | 欧美日韩在线综合 | 日韩欧美国产精品一区 | 欧美成年视频 | 久久久久九九九九 | 欧美一区视频 | 亚洲日韩中文字幕一区 | 久久只有精品 | 91久久精品一区二区二区 | 毛片网站在线观看视频 | 免费在线性爱视频 | 欧美一区二区三区在线视频 | 日批免费看 | 国产美女在线观看 | 欧美一区日韩一区 | 午夜视频免费在线观看 | 国产视频一区二区三区四区五区 | 中文字幕在线观看第一页 | 波多野吉衣在线播放 | 华丽的挑战在线观看 | 国产视频不卡一区 | www.色.com| 国产黄色网址在线观看 | 99福利视频导航 | 国产精品久久一区二区三区 | 天天澡天天操 | 中文字幕一区二区三区四区不卡 |