Is it possible to inline LESS stylesheets?

2019-01-23 10:33发布

问题:

For example, is it possible to do something like:

<style type="text/less">
  #foo {
    .bar {
       font-weight: bold;
    }
  }
</style>

回答1:

This has been possible since July 2010, and it works with today's Less 1.2.0 version.

See the initial diff that added support for this.



回答2:

You actually need to use

<style type="text/less">

instead of:

<style type="stylesheet/less">

Otherwise it won't work.

Remember to place the <style> element before the <script> element to load less.js.



标签: css less