哪个更好:SASS 或带 aspx 的动态 css?
我今天就有一个疑问。我读过 Sass 网站并尝试了一些东西,我认为它很棒。非常灵活和强大。然而,在 Windows 中使用它时有点麻烦,因为我必须安装 Ruby,每次都运行 sass watch 命令,所以它为我的开发环境添加了更多步骤。 对我来说,Sass 的最大优势是可维护性,因为它允许您通过很少的步骤来分解和展开更改。 所以我今天想我可以只使用一个返回其 contentType = text/css 的 asp 文件,然后使用动态标记来绕过、因式分解等。
比如:
<%
Response.ContentType = "text/css"
%>
<%
color = "#AAAAAA"
%>
fieldset {
padding: 15px 10px 15px 10px;
background-color: <%= color %>;
}
.FieldColumnLeft, .FieldColumnMiddle, .FieldColumnRight {
float:left;
}
所以我的问题(足以用于介绍)是,哪一个是更好地考虑可维护性、灵活性等?我知道 asp 会命中 Web 服务器处理器,但通过输出缓存,我可以只缓存输出,这样命中只会是第一次。
你怎么认为?
I have a doubt that came up to me just today. I've read Sass website and tried a bit of things and I think it's great. Very flexible and powerful. However it was kind of a hassle when using it in Windows because I had to install Ruby, run the sass watch command everytime so it added more steps to my development environment.
To me, the greatest advantage of Sass is maintanability because it allows you to factor and spread out changes in a very few steps.
So I thought today that I could just use an asp file that returns its contentType = text/css and just use dynamic markup to get around, factorize, etc.
Something like:
<%
Response.ContentType = "text/css"
%>
<%
color = "#AAAAAA"
%>
fieldset {
padding: 15px 10px 15px 10px;
background-color: <%= color %>;
}
.FieldColumnLeft, .FieldColumnMiddle, .FieldColumnRight {
float:left;
}
So my question (enough for the introduction) is, which one is better considering maintanability, flexibility, etc.? I know that the asp will hit the web server processor but with output caching I could just cache the output so the hit would be the first time only.
What do you think?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们在 .less 方面拥有丰富的经验,它与 SASS 和 与它一起工作的 Chirpy Visual Studio 插件。它在编译期间创建最终的 css,并缩小和连接。
恕我直言,这是一个比修改动态创建的 css 更好的解决方案,并且当速度存在问题时,它还允许您将 css 文件放到 CDN 上。
We had great experience with .less which is somewhat similar to SASS and the Chirpy Visual Studio plugin that works together with it. It creates the final css during compile and minifies and concatenates as well.
IMHO this is a much better solution then tinkering with dynamically created css and it also allows you to put the css files onto a CDN when speed is an issue.