久久久久久久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?)
主站蜘蛛池模板: 特黄色一级毛片 | 日本一区二区高清视频 | 福利网址 | 久久久久国产精品午夜一区 | 91亚洲精品久久久电影 | 一区二区三区在线播放视频 | 日韩视频精品在线 | 先锋资源网 | 久色一区| 欧美亚洲综合久久 | 国产精品视频免费观看 | 国产精品久久久久久久久久软件 | 国产精品区二区三区日本 | 青青草视频网站 | 日韩精品一区二区三区四区 | 伊人久久大香线 | 亚洲在线成人 | 成人在线视频免费看 | 成人欧美一区二区三区在线播放 | 少妇一级淫片aaaaaaaaa | 亚洲欧美另类在线 | 在线激情视频 | 91成人免费看 | 秋霞在线一区 | www.国产视频 | 国产美女久久久 | 亚洲成av | 亚洲欧美一区二区三区视频 | 暖暖日本在线视频 | 香蕉视频一区二区 | 在线三级网址 | 国产高清视频一区 | 亚洲色图在线观看 | 欧美日韩视频一区二区 | 欧美日韩国产一区二区三区 | 亚洲免费在线播放 | 国产福利视频网站 | 亚洲二区精品 | 乳色吐息在线观看 | 中文在线a在线 | 久久r免费视频 |