我有以下 CSS:
&.fixed-map {
width: 100%!important;
position: fixed!important;
left: 0;
}
&.under-750 {
width: 100%!important;
position: static;
}
&.over-1025 {
position: static;
}
从 CSS 的 Angular 来看,这会提升性能吗?
&.fixed-map,
&.under-750 {
width: 100%!important;
}
&.under-750,
&.over-1025 {
position: static;
}
&.fixed-map {
position: fixed!important;
left: 0;
}
或者它只是编写 CSS 的一种更好的方式?
最佳答案
从敏捷的 Angular 来看,我肯定会使用第一种方式。 这种优化(如果真的是优化)将由机器处理。不是编码员。
想象一下,您想修改 .under-750
的宽度。
使用第一种方式。
旁注:仅将 important!
用作最后的可能性。
关于应用 CSS DRY 概念,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30892052/