parse css

作者: Time_Notes | 来源:发表于2020-06-06 16:15 被阅读0次

    Style sheets

    Style sheets on the other hand have a different model. Conceptually it seems that since style sheets don't change the DOM tree, there is no reason to wait for them and stop the document parsing. There is an issue, though, of scripts asking for style information during the document parsing stage. If the style is not loaded and parsed yet, the script will get wrong answers and apparently this caused lots of problems. It seems to be an edge case but is quite common. Firefox blocks all scripts when there is a style sheet that is still being loaded and parsed. WebKit blocks scripts only when they try to access certain style properties that may be affected by unloaded style sheets.


    CSS解析

    一旦浏览器下载了CSS,CSS解析器就会处理它遇到的任何CSS,根据语法规范解析出所有的CSS 并进行标记化,然后得到一个规则表。

    CSS匹配规则

    在匹配一个节点对应的CSS规则时,是按照从右到左的顺序的,例如:div p { font-size :14px }会先寻找所有的p标签然后判断它的父元素是否为div。

    所以写CSS时,尽量用id和class,千万不要过度层叠。


    cssom树生成过程

    相关文章

      网友评论

          本文标题:parse css

          本文链接:https://www.haomeiwen.com/subject/jhkvbhtx.html