gpt4 book ai didi

css - CSS 星号选择器是否被认为是有害的(为什么)?

转载 作者:行者123 更新时间:2023-11-28 06:21:47 25 4
gpt4 key购买 nike

CSS中的星号选择器会影响页面渲染性能吗?

使用它有什么注意事项吗?

* {
margin:0;
padding:0;
}

最佳答案

在性能方面,Steve Souders 是人:

引用其中一篇报道的无耻话:

The key to optimizing CSS selectors is to focus on the rightmost selector, also called the key selector (coincidence?). Here’s a much more expensive selector: A.class0007 * {}. Although this selector might look simpler, it’s more expensive for the browser to match. Because the browser moves right to left, it starts by checking all the elements that match the key selector, “*“. This means the browser must try to match this selector against all elements in the page.

[大胆强调我的]

关于css - CSS 星号选择器是否被认为是有害的(为什么)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35547378/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com