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

CSS 選擇器 ul li a {...} vs ul >李>一個(gè) {...}

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

問題描述

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

推薦答案

">" 是 子選擇器

"" 是 后代選擇器

區(qū)別在于后代可以是元素的子元素,也可以是元素的子元素的子元素,也可以是子元素的子元素的子元素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>

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

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

關(guān)于你的第二個(gè)問題:

哪個(gè)更高效,為什么?

我實(shí)際上不會回答這個(gè)問題,因?yàn)樗c開發(fā)完全無關(guān).CSS 渲染引擎的速度如此之快,幾乎沒有* 優(yōu)化 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.

與其擔(dān)心微優(yōu)化,不如專注于編寫對當(dāng)前案例有意義的選擇器.在為嵌套列表設(shè)置樣式時(shí),我經(jīng)常使用 > 選擇器,因?yàn)閰^(qū)分正在設(shè)置樣式的列表級別很重要.

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.

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

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

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

相關(guān)文檔推薦

CSS selector when :target empty(:target 為空時(shí)的 CSS 選擇器)
Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在選擇性方面沒有任何價(jià)值嗎?)
Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的結(jié)果是否有序?)
Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯(cuò)誤:當(dāng)使用 JS 刪除項(xiàng)目時(shí),first-child 不更新 display:block)
nth-Child CSS selectors(nth-子 CSS 選擇器)
Using same ID for multiple HTML tags?(對多個(gè) HTML 標(biāo)簽使用相同的 ID?)
主站蜘蛛池模板: 午夜国产福利 | 国产欧美一区二区精品性色超碰 | 午夜国产福利 | 国产永久在线 | 日韩欧美网站 | 伊人久久av | 久艹在线 | 日韩有码在线视频 | 99cao| 日本一区二区不卡 | av免费看片 | 亚洲精品日韩精品 | 国产精品一区二区三区在线 | 黄色一级小说 | 日本一区二区不卡 | 日韩成人在线播放 | 六月丁香激情 | 香蕉在线播放 | 小日子的在线观看免费第8集 | 人人爽人人爽人人 | 国产精品久久久久久妇女6080 | 免费91网站| 91av精品| 欧美一区二区在线视频 | 超碰人人人人 | 婷婷中文字幕 | 精品久久久久久久久久久久久久久久 | 超碰在线观看97 | 超碰福利在线 | 欧洲性视频 | 精品免费国产一区二区三区四区 | 国产视频一区在线播放 | 国产第三页 | 伊人国产精品 | 97操碰 | 特大黑人巨交吊性xxxx视频 | 成人高潮片免费网站 | 欧美激情亚洲 | a级片免费 | 中文字幕精品视频 | 热久久中文字幕 |