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

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

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

問題描述

寫一段代碼,我注意到我在一個地方寫了>:first-child 及以后的 >*:first-child.兩個塊似乎都可以正常工作,但兩者之間有區(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 應該和 > 的意思一樣.*:first-child 用于瀏覽器.

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

你也可以閱讀

注意:建議不要省略 * ,因為這樣可以減少例如 div :first-childdiv 之間的潛在混淆:第一個孩子.在這里,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ī)范中我們還可以閱讀:

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

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

注意:在某些情況下,添加通用選擇器可以使選擇器更易于閱讀,即使它對匹配行為沒有影響.例如,div :first-childdiv:first-child 乍一看有點難以區(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.

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

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

相關文檔推薦

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 選擇器的工具?)
主站蜘蛛池模板: 亚洲精品美女在线观看 | 精精国产xxxx视频在线野外 | 国产美女特级嫩嫩嫩bbb片 | 欧美男人的天堂 | 国产精品久久久久久高潮 | 九九99九九精彩46 | xx视频在线 | 天天天操 | 91视频a| 九色.com| 精品视频在线一区 | 亚洲国产高清高潮精品美女 | 高清黄色网址 | 北条麻妃一区二区三区在线视频 | 成人影院网站ww555久久精品 | 精品亚洲一区二区 | 久久成人精品视频 | 国产激情一区二区三区 | 久草新在线 | 欧美成视频 | 久久精品色欧美aⅴ一区二区 | 国产一区二区精品 | 日韩欧美在线视频 | 国产粉嫩尤物极品99综合精品 | 福利视频二区 | 综合久久亚洲 | 一区中文字幕 | 欧美精品在线观看 | 日韩国产一区二区三区 | 久久99精品久久久久久国产越南 | 日本不卡一区二区 | a视频在线观看 | 九色91视频| 在线不卡视频 | 国产激情精品一区二区三区 | 国产福利在线播放麻豆 | 国产美女在线看 | 国产主播第一页 | 成人在线一区二区 | 自拍偷拍小视频 | 久久99精品久久久久久国产越南 |