多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
* 对于通用元素使用 class ,这样利于渲染性能的优化。 * 对于经常出现的组件,避免使用属性选择器(例如,`[class^="..."]`)。浏览器的性能会受到这些因素的影响。 * 选择器要尽可能短,并且尽量限制组成选择器的元素个数,建议不要超过 3 。 * **只有**在必要的时候才将 class 限制在最近的父元素内(也就是后代选择器)(例如,不使用带前缀的 class 时 -- 前缀类似于命名空间)。 扩展阅读: * [Scope CSS classes with prefixes](http://markdotto.com/2012/02/16/scope-css-classes-with-prefixes/) * [Stop the cascade](http://markdotto.com/2012/03/02/stop-the-cascade/) ~~~ /* Bad example */ span { ... } .page-container #stream .stream-item .tweet .tweet-header .username { ... } .avatar { ... } /* Good example */ .avatar { ... } .tweet-header .username { ... } .tweet .avatar { ... } ~~~