久久久久久久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 選擇器的工具?)
主站蜘蛛池模板: 国产a视频 | 一区二区三区亚洲视频 | 精品国产一区二区三区久久久蜜月 | 一区二区三区av夏目彩春 | 国产免费播放视频 | 日韩中文视频 | 91麻豆精品国产91久久久久久 | 国产精品毛片av一区 | 中文字幕在线一区 | 国产精品99久久久久久久vr | 四虎影院新网址 | 成人性视频免费网站 | 国产传媒视频在线观看 | 精品亚洲一区二区三区 | 九色一区 | 国产欧美一区二区三区久久 | 久久免费视频观看 | 国产精品国产 | 日韩一区二区免费视频 | 亚洲成av | 午夜精品一区 | 91精品国产高清久久久久久久久 | 久久亚洲一区二区三区四区 | 一级做a | 麻豆国产一区二区三区四区 | com.色.www在线观看 | 亚洲一区二区三区在线免费观看 | 成人小视频在线观看 | 99这里只有精品视频 | 国产福利视频导航 | 国产精品高 | 久久亚洲精品国产精品紫薇 | 免费看片国产 | 欧美精品一区二区在线观看 | 亚洲视频中文字幕 | 日韩精品一区二区三区视频播放 | 久久69精品久久久久久久电影好 | 欧美久久久久 | 夜夜骚| 国产不卡在线播放 | 国产在线视频在线观看 |