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

當您特定時,CSS 會更快嗎?

Is CSS faster when you are specific?(當您特定時,CSS 會更快嗎?)
本文介紹了當您特定時,CSS 會更快嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

div.container.container 快嗎?你知道在 jquery 中,如果你更具體地使用你的選擇器,它會更快,因為它迭代更少.. css 是這種情況嗎?

Is div.container faster than .container ? You know like in jquery if you be more specific with your selectors it is faster since it iterates through less.. Is this the case with css ?

有沒有辦法衡量 css 的性能?性能方面,這樣的事情是否重要,或者它基本上都取決于文本重量?

Is there a way to measure performance in css ? Performance wise, does things like this even matter or does it all depend on text weight basically ?

如果有人知道答案,我會很高興,我實際上發現了一個沒有確定答案的類似問題.如果指定得更好,CSS會更高效嗎?

I'd be happy if someone knows the answer to it, I've actually found a similar question with no certain answer. Can CSS be more efficient if it is better specified?

推薦答案

在現實世界中,速度差異可以忽略不計.
技術方面的 .container 會更快,因為它需要處理的選擇器更少.

In real world the speed difference would be negligible.
To be technical .container would be faster as it has fewer selectors to process.

選擇器具有固有的效率.CSS 選擇器從高到低的順序是這樣的:

Selectors have an inherent efficiency. The order of more to less efficient CSS selectors goes thus:

  1. ID,例如#header
  2. 類,例如.promo
  3. 類型,例如div
  4. 相鄰的兄弟,例如h2 + p
  5. 孩子,例如李>ul
  6. 后裔,*例??如ul a*
  7. 通用,*
  8. 屬性,例如[type="text"]
  9. 偽類/元素,例如a:hover

關于你的第二個問題:

有沒有辦法衡量 CSS 的性能?

Is there a way to measure performance in CSS ?

Steve Souders 推出了一項在線測試來衡量 CSS 的性能,仍然可以在此處訪問該測試.

Steve Souders put out an online test to measure performance of CSS that can still be accessed here.

現在有更好的方法來衡量性能,但這是一種快速簡便的資源,您可以使用.

There are better ways to measure performance nowadays, but this is a quick and easy resource you can play with.

在性能方面,這樣的事情是否重要,或者它基本上都取決于文本重量?

Performance wise, does things like this even matter or does it all depend on text weight basically ?

簡短的回答是不是真的".

The short answer is "not really".

答案很長,視情況而定".如果你在一個簡單的網站上工作,除了一般知識之外,你真的沒有必要對 CSS 性能大驚小怪,你可以從最佳實踐中獲得.

The long answer is, "it depends". If you are working on a simple site there is really no point to make a fuss about CSS performance other than general knowledge you may gain from best practices.

如果您要創建一個包含數萬個 DOM 元素的網站,那么是的,這很重要.

If you are creating a site with tens of thousands of DOM elements then yes, it will matter.

這篇關于當您特定時,CSS 會更快嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

:hover:before text-decoration none has no effects?(:hover:before text-decoration none 沒有效果?)
CSS sibling selectors (select all siblings)(CSS 兄弟選擇器(選擇所有兄弟))
IE: nth-child() using odd/even isn#39;t working(IE:使用奇數/偶數的 nth-child() 不起作用)
How can I tell if an element is in a shadow DOM?(如何判斷一個元素是否在影子 DOM 中?)
Can I use CSS to add a bullet point to any element?(我可以使用 CSS 為任何元素添加項目符號嗎?)
CSS attribute selector for non-empty attributes(非空屬性的 CSS 屬性選擇器)
主站蜘蛛池模板: 国产不卡在线观看 | 国产精品成人一区二区三区 | 国产精品呻吟久久av凹凸 | 久久亚洲国产精品日日av夜夜 | 国产成人一区 | 国产免费一区二区三区免费视频 | 一区二区视频免费观看 | 成人在线视频免费观看 | 色本道| 91在线精品一区二区 | 国内自拍视频在线观看 | 日韩精品在线观看网站 | 亚洲成人在线视频播放 | 国产视频在线一区二区 | 国产精品久久欧美久久一区 | 欧美mv日韩mv国产网站91进入 | av官网在线| 在线免费视频一区 | 超碰97人人人人人蜜桃 | 91精品国产日韩91久久久久久 | 欧美日韩国产高清视频 | 欧美精品一区二区三区蜜臀 | 国产视频一区二区在线观看 | 亚洲视频自拍 | 成人av看片 | 精品人伦一区二区三区蜜桃网站 | 在线色 | 黄色成人在线观看 | 午夜视频在线免费观看 | 国产精品一区二区av | 欧美日韩亚洲视频 | 一本色道精品久久一区二区三区 | 免费福利视频一区二区三区 | 精品视频一区二区三区 | 天堂精品 | 久久精品一区 | 美女日皮网站 | 欧美精品91 | 91在线精品一区二区 | 久久精品一区 | 一区二区三区在线 |