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

CSS 選擇器 ul li a {...} vs ul >李>一個 {...}

CSS selectors ul li a {...} vs ul gt; li gt; a {...}(CSS 選擇器 ul li a {...} vs ul 李gt;一個 {...})
本文介紹了CSS 選擇器 ul li a {...} vs ul >李>一個 {...}的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

  1. ul>有什么區別?李>CSS 中的 {...}ul li a {...}?
  2. 哪個效率更高,為什么?

推薦答案

">" 是 子選擇器

"" 是 后代選擇器

區別在于后代可以是元素的子元素,也可以是元素的子元素的子元素,也可以是子元素的子元素的子元素ad inifinitum.

The difference is that a descendant can be a child of the element, or a child of a child of the element or a child of a child of a child ad inifinitum.

子元素只是直接包含在父元素中的元素:

A child element is simply one that is directly contained within the parent element:

<foo> <!-- parent -->
  <bar> <!-- child of foo, descendant of foo -->
    <baz> <!-- descendant of foo -->
    </baz>
  </bar>
</foo>

對于這個例子,foo * 將匹配 <bar><baz>,而 foo >* 只會匹配 <bar>.

for this example, foo * would match <bar> and <baz>, whereas foo > * would only match <bar>.

關于你的第二個問題:

哪個更高效,為什么?

我實際上不會回答這個問題,因為它與開發完全無關.CSS 渲染引擎的速度如此之快,幾乎沒有* 優化 CSS 選擇器的理由,只需要使它們盡可能短.

I'm not actually going to answer this question as it's completely irrelevant to development. CSS rendering engines are so fast that there is almost never* a reason to optimize CSS selectors beyond making them as short as possible.

與其擔心微優化,不如專注于編寫對當前案例有意義的選擇器.在為嵌套列表設置樣式時,我經常使用 > 選擇器,因為區分正在設置樣式的列表級別很重要.

Instead of worrying about micro-optimizations, focus on writing selectors that make sense for the case at hand. I often use > selectors when styling nested lists, because it's important to distinguish which level of the list is being styled.

* 如果在渲染頁面時確實是一個問題,那么你可能在頁面上有太多元素,或者 CSS 太多.然后你必須運行一些測試來看看實際的問題是什么.

這篇關于CSS 選擇器 ul li a {...} vs ul >李&gt;一個 {...}的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

CSS selector when :target empty(:target 為空時的 CSS 選擇器)
Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在選擇性方面沒有任何價值嗎?)
Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的結果是否有序?)
Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯誤:當使用 JS 刪除項目時,first-child 不更新 display:block)
nth-Child CSS selectors(nth-子 CSS 選擇器)
Using same ID for multiple HTML tags?(對多個 HTML 標簽使用相同的 ID?)
主站蜘蛛池模板: av免费网站在线观看 | 日韩在线综合网 | 国产日韩精品久久 | 亚洲一区二区在线播放 | 亚洲欧美日韩一区二区 | 久久国产日韩 | 欧美精品在线观看 | 成人精品系列 | 国产一区二区在线免费观看 | 久热精品视频 | 欧美日韩精品一区二区三区蜜桃 | 免费在线观看一区二区 | 蜜桃在线视频 | 久久久久久九九九九九九 | 成人久久久 | 超碰91在线 | 在线观看国产 | 麻豆精品一区二区三区在线观看 | av在线免费网站 | 国产日韩精品一区二区三区 | 日韩免费高清视频 | 精品一二三区视频 | 亚洲综合资源 | 国产激情在线播放 | 国产精品视频综合 | 欧美一区视频在线 | 成人精品一区二区三区 | 成人免费视频一区二区 | 欧美日韩在线精品 | 亚洲成人国产综合 | 久久国产精99精产国高潮 | 成人毛片视频在线播放 | 性色视频 | www.成人久久 | 久久99视频免费观看 | 日韩在线观看一区二区三区 | 国产欧美在线视频 | 亚洲视频网 | 秋霞a级毛片在线看 | 欧美日韩在线观看视频网站 | 日韩三级电影在线看 |