【发布时间】:2013-05-14 00:49:47
【问题描述】:
以前没有 SASS,如果类共享相同的 CSS 属性,则更容易将它们分组如下
.header, .content, .footer {
height:100%;
}
但是使用 SASS/SCSS 等管理样式要容易得多。 所以问题是考虑到下面的 mixin 的 CSS 性能考虑
@mixin sameHeight{
height:100%;
}
实现应该是
.content {
@include sameHeight;
}
.footer {
@include sameHeight;
}
.header {
@include sameHeight;
}
/* CSS OUTPUT */
.header {
height:100%;
}
.content{
height:100%;
}
.footer{
height:100%;
}
应该是这样
.header, .content, .footer {
@include sameHeight;
}
/* CSS OUTPUT */
.header, .content, .footer {
height:100%;
}
【问题讨论】:
-
关注可维护性,性能差异很小。确保在生产环境中最小化和 gzip。
-
我不认为有太多的可维护性问题,但如果你有这样的s1.wp.com/wp-content/themes/pub/twentytwelve/…,性能可能会受到影响
标签: html css performance sass