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

CSS 中的 * 和 *|* 有什么區別?

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

問題描述

在 CSS 中,* 將匹配任何元素.

In CSS, * will match any element.

經常使用 *|* 代替 * 來匹配所有元素.這通常用于測試目的.

Frequently, *|* is used instead of * to match all elements. This is generally used for testing purposes.

**|*在CSS中有什么區別?

What is the difference between * and *|* in CSS?

推薦答案

根據 W3C選擇器規范:

通用選擇器允許一個可選的命名空間組件.用法如下:

The universal selector allows an optional namespace component. It is used as follows:

ns|*
命名空間 ns 中的所有元素

ns|*
all elements in namespace ns

*|*
所有元素

|*
所有沒有命名空間的元素

|*
all elements without a namespace

*
如果沒有指定默認命名空間,這相當于 *|*.否則,它等效于 ns|*,其中 ns 是默認命名空間.

*
if no default namespace has been specified, this is equivalent to *|*. Otherwise it is equivalent to ns|* where ns is the default namespace.

所以,沒有 **|* 并不總是相同的.如果提供了默認名稱空間,則 * 僅選擇屬于該名稱空間的元素.

So, no * and *|* are not always the same. If a default name space is provided then * selects only elements that are part of that namespace.

您可以使用以下兩個片段直觀地看到差異.首先,定義了默認命名空間,因此 * 選擇器僅將米色背景應用于作為該命名空間一部分的元素,而 *|* 應用所有元素的邊框.

You can visually see the differences using the below two snippets. In the first, a default namespace is defined and so the * selector applies the beige colored background only to the element which is part of that namsepace whereas the *|* applies the border to all elements.

@namespace "http://www.w3.org/2000/svg";

* {
  background: beige;
}
*|* {
  border: 1px solid;
}

<a href="#">This is some link</a>

<svg xmlns="http://www.w3.org/2000/svg">
  <a xlink:href="#">
    <text x="20" y="20">This is some link</text>
  </a>
</svg>

在下面的代碼片段中,沒有定義默認命名空間,因此 **|* 都適用于所有元素,因此所有元素都獲得米色背景和黑色邊框.換句話說,當沒有指定默認命名空間時,它們的工作方式相同.

In the below snippet no default namespace is defined and so both * and *|* applies to all elements and so all of them get both the beige background and the black border. In other words, they work the same way when no default namespace is specified.

* {
  background: beige;
}
*|* {
  border: 1px solid;
}

<a href="#">This is some link</a>

<svg xmlns="http://www.w3.org/2000/svg">
  <a xlink:href="#">
    <text x="20" y="20">This is some link</text>
  </a>
</svg>

正如 BoltClock 在評論中指出的那樣 (1,2),最初命名空間僅適用于基于 XML 的語言,例如 XHTML、SVG 等,但根據最新規范,所有 HTML 元素(即 HTML 命名空間中的元素)都被命名為 http://www.w3.org/1999/xhtml.Firefox 遵循這種行為,并且在所有 HTML5 用戶代理中都是一致的.您可以在此答案中找到更多信息.

As BoltClock points out in comments (1,2), initially namespaces applied only to XML based languages such as XHTML, SVG etc but as per latest specs, all HTML elements (that is, elements in the HTML namespace) are namespaced to http://www.w3.org/1999/xhtml. Firefox follows this behavior and it is consistent across all HTML5 user agents. You can find more information in this answer.

這篇關于CSS 中的 * 和 *|* 有什么區別?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

:hover:before text-decoration none has no effects?(:hover:before text-decoration none 沒有效果?)
Is CSS faster when you are specific?(當您特定時,CSS 會更快嗎?)
CSS sibling selectors (select all siblings)(CSS 兄弟選擇器(選擇所有兄弟))
IE: nth-child() using odd/even isn#39;t working(IE:使用奇數/偶數的 nth-child() 不起作用)
How can I tell if an element is in a shadow DOM?(如何判斷一個元素是否在影子 DOM 中?)
Can I use CSS to add a bullet point to any element?(我可以使用 CSS 為任何元素添加項目符號嗎?)
主站蜘蛛池模板: 国产在线一区二区三区 | 欧美高清视频 | 日韩一区二区免费视频 | 精品国产乱码久久久久久88av | 久久久久久久久久久久久久av | 黄网站免费在线看 | 久久91 | 日日日操 | 日本精品裸体写真集在线观看 | 精品国产一区探花在线观看 | 婷婷桃色网 | 久久久久免费精品国产 | 在线国产视频 | 精品国产91乱码一区二区三区 | 成人免费视频在线观看 | 国产乱码精品1区2区3区 | 波多野吉衣在线播放 | 伊人精品视频 | 精品欧美一区二区三区免费观看 | 国产精品久久久久一区二区三区 | 男女视频在线观看免费 | 国产精品色哟哟网站 | 午夜免费在线 | 精品欧美一区免费观看α√ | 精品亚洲一区二区 | 国产欧美一区二区三区日本久久久 | 自拍视频网站 | 成人欧美一区二区三区视频xxx | 欧美成视频 | 超碰97人人人人人蜜桃 | 日韩一区二区在线观看视频 | 午夜精品久久久久久 | 亚洲精品国产电影 | 欧美videosex性极品hd | 嫩草视频入口 | www.788.com色淫免费 | 欧美精品在线免费观看 | 色综久久 | 一区二区三区在线看 | 91亚洲精选| 在线视频三区 |