CSS Performance Question

后端 未结 8 2034
挽巷
挽巷 2020-12-18 06:51

I was wondering what the experts do when it comes to writing CSS code. Is it bad to use the tagname.className style? Does inheritance cause a noticeable performance loss? Do

8条回答
  •  遥遥无期
    2020-12-18 07:02

    Poor css can definitely impact rendering, however I don't believe it would impact scrolling once rendered. In your example, at least avoid the selectors 3 levels deep. Single level css selectors will be faster than double level selectors. Putting the tag type should speed up the selection process, because instead of matching *.class in your DOM document, it only has to match div.class, filtering the type of dom nodes you are having to look at class for.

提交回复
热议问题