少有什么好处?
是的,该语言语法看起来很酷,但是有什么显着的优点吗?
因为从我看来,你实际上编写了更多的 CSS,并且由于 javascript 编译了更少的样式表,所以你会在几秒钟内得到一个未样式化的网站......
Yeah the language syntax looks cool, but are there any significant advantages?
Because from what I see there you actually write more CSS, and since the less stylesheet gets compiled by javascript you get a un-styled site for a few seconds...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
也就是说,如果您使用 lesscss 来生成客户端工作表。
您还可以在服务器端使用lesscss,甚至可以预先编译您的工作表。
例如,如果您使用 node.js,您可以在服务器上生成工作表。
此外,如果您愿意,您可以使用它来编写更易于管理的模板,然后“编译”您的工作表以生成成型的样式表,以便您在阅读生产时使用。
我认为这是完全有道理的,因为这意味着当您处于开发阶段时,您可以通过单个十六进制颜色更改来更改颜色集合。当您准备好部署时,您可以预先编译,然后将该样式表与您的项目一起分发。
考虑可管理性并使用命令行编译器。
命令行
这会将编译后的 CSS 输出到 stdout,然后您可以将其重定向到您选择的文件:
要输出缩小的 CSS,只需传递 -x 选项。
That is if you use lesscss for client side sheet generation.
You can also use lesscss on the server side or even compile your sheets before hand.
For example, if you are using node.js you can generate your sheets on the server.
Additionally, if you want, you can use it as a way to write more manageable templates and then "compile" your sheets to generate a formed style sheet for when you are reading for production.
I think it makes perferct sense, because it means that while you are in development, you can change a collection of colors in a single hex color change. When you are ready to deploy, you can compile before hand and then distribute that style sheet with your project.
Think about manageability and using the command line compiler.
Command Line
This will output the compiled CSS to stdout, you may then redirect it to a file of your choice:
To output minified CSS, simply pass the -x option.
为什么要使用 LESS 编写更多 CSS?反之,你就写得少了。而且你编写的代码比普通的 CSS 更加冗长。您可以更好地创建组、使用继承...您只是比使用 CSS 更好地概述样式。
我的项目 CSS 文件目前有超过 800 行...在 LESS 中,只有 150 行左右。
对于 javascript 编译:我通常使用离线编译器并只上传编译后的 CSS,所以我不必与 JS 客户端大惊小怪。
Why would you write more CSS using LESS? In the contrary, you write less. And the code that you write is way more verbose than normal css. You can create groups better, use inheritance... You just have a way better overview over your styling than you do with CSS.
My CSS-file for a project currently has over 800 lines... in LESS, it's just around 150.
And to the javascript-compiling: I generally use an offline compiler and upload just the compiled CSS, so I don't have to fuss with the JS client.
你可以使用预编译器(ruby 有一个很酷的预编译器,可以在 win 下运行)。
尝试用 less 编写一个网站,你将永远不想再回到正常的 css :) 我自己的经验......
You can use a precompiler (ruby's got a cool one, got it running under win).
Try writing a site in less and you'll never want to get back to normal css again :) my own experience...
实际上有一个 LESS PHP 编译器,我一直在使用它。我认为弄清楚为什么它比 CSS 更好的最好方法是自己使用它,但我会总结一些事情:
是的,语言语法看起来很酷
我个人认为这是相当轻蔑和无知的;如果您查看一下 LESS 示例,您会发现它在可用性和开发速度方面比普通 CSS 领先英里。还有更多原因,但这些应该足以让您开始。
There is actually a LESS PHP compiler, which I use all the time. I think the best way to work out why it's better than CSS is to use it yourself, but I'll summarise some things:
Yeah the language syntax looks cool
Personally I think this is rather dismissive and ignorant; if you have a look around the LESS examples, you will see it is miles ahead of normal CSS in terms of usability and speed of development.There are more reasons, but these should be enough to get you started.