Progressive enhancement - The practice of building an application for a base level of user experience, but adding functional enhancements when a browser supports it.
首先,欣赏器从最右边的选择器,即关键选择器(key selector),向左依次匹配。根据关键选择器,欣赏器从 DOM 中筛选出元素,然后向上遍历被选元素的父元素,判断是否匹配。选择器匹配语句链越短,欣赏器的匹配速度越快。克制使用标签和通用选择器作为关键选择器,因为它们会匹配大量的元素,欣赏器必须要进行大量的工作,去判断这些元素的父元素们是否匹配。
BEM (Block Element Modifier) methodology recommends that everything has a single class, and, where you need hierarchy, that gets baked into the name of the class as well, this naturally makes the selector efficient and easy to override. BEM (Block Element Modifier)原则上发起为独立的 CSS 类定名,而且在必要层级关系时,将关系也体如今定名中,这自然会使选择器高效且易于覆盖。
搞清楚哪些 CSS 属性会触发重新结构(reflow)、重绘(repaint)和合成(compositing)。在写样式时,克制触发重新结构的大概。
参考资料:
developers.google.com/web/fundame…
csstriggers.com/
10.使用 CSS 预处置惩罚的优缺点分别是什么?
长处:
进步 CSS 可维护性。
易于编写嵌套选择器。
引入变量,增长主题功能。可以在不同的项目中共享主题文件。
通过混淆(Mixins)天生重复的 CSS。
Splitting your code into multiple files. CSS files can be split up too but doing so will require a HTTP request to download each CSS file.