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

> 之間是否存在功能差異?*:first-child 和 &am

Is there a functional difference between gt; *:first-child and gt; :first-child?(gt; 之間是否存在功能差異?*:first-child 和 gt;:第一個(gè)孩子?)
本文介紹了> 之間是否存在功能差異?*:first-child 和 >:第一個(gè)孩子?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

寫一段代碼,我注意到我在一個(gè)地方寫了>:first-child 及以后的 >*:first-child.兩個(gè)塊似乎都可以正常工作,但兩者之間有區(qū)別嗎?

Writing a block of code, I noticed that in one place I wrote > :first-child and later on > *:first-child. Both blocks appear to be functional, but is there a difference between the two?

推薦答案

即使我們考慮性能,它們也是相同的.從規(guī)范我們可以閱讀

They are identical even if we consider performance. From the specification we can read

如果由 * 表示的通用選擇器(即沒有命名空間前綴)不是簡單選擇器選擇器序列的唯一組成部分或緊隨其后的是偽元素,則 * 可以省略 和通用選擇器的存在隱含.

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.

所以寫>:first-child 應(yīng)該和 > 的意思一樣.*:first-child 用于瀏覽器.

So writing > :first-child should mean the same as > *:first-child for the browser.

你也可以閱讀

注意:建議不要省略 * ,因?yàn)檫@樣可以減少例如 div :first-childdiv 之間的潛在混淆:第一個(gè)孩子.在這里,div *:first-child 更具可讀性.

Note: it is recommended that the * not be omitted, because it decreases the potential confusion between, for example, div :first-child and div:first-child. Here, div *:first-child is more readable.

因此,這不僅是偏好問題,而且有助于避免混淆并使代碼更具可讀性.

So it's not only a matter of preference but it helps avoid confusion and make the code more readable.

在新規(guī)范中我們還可以閱讀:

除非元素是無特征的,否則通用選擇器的存在對(duì)元素是否匹配選擇器沒有影響.

Unless an element is featureless, the presence of a universal selector has no effect on whether the element matches the selector.

注意:在某些情況下,添加通用選擇器可以使選擇器更易于閱讀,即使它對(duì)匹配行為沒有影響.例如,div :first-childdiv:first-child 乍一看有點(diǎn)難以區(qū)分,但將前者寫為 div *:first-child 讓區(qū)別顯而易見.

Note: In some cases, adding a universal selector can make a selector easier to read, even though it has no effect on the matching behavior. For example, div :first-child and div:first-child are somewhat difficult to tell apart at a quick glance, but writing the former as div *:first-child makes the difference obvious.

這篇關(guān)于> 之間是否存在功能差異?*:first-child 和 >:第一個(gè)孩子?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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 選擇器的工具?)
主站蜘蛛池模板: 亚洲精品字幕在线观看 | 国产a久久麻豆入口 | 天堂网亚洲 | 亚洲欧美久久 | 伊人91 | 四虎在线免费视频 | 日日操日日干 | 五月婷婷丁香花 | 久久精品国产视频 | 黄色aaa| 色网站女女 | 久久久综合网 | 成人激情在线观看 | 一区二区三区影视 | www.一区二区三区 | 国产精品成人一区二区三区 | 一本伊人 | 91成人在线 | 日韩精品毛片 | 亚洲最新视频 | 欧美激情视频网站 | 精品国产一区二区三区久久久蜜月 | 成人午夜毛片 | 91美女片黄在线观看91美女 | 国产一级黄色大片 | 日韩中文字幕在线视频 | 国产一区二区久久 | 完全免费av| 亚洲人成免费 | 在线看黄的网站 | 欧美一区二区三区在线观看 | 久久精品欧美一区二区三区不卡 | 黄色一级片免费 | 伊人精品在线 | 久久久久久久网 | 三级理论片 | 日韩精品一区在线观看 | a级一级片 | 亚洲精品综合 | 神马福利视频 | www.伊人网|