Mixin using LESS

2019-06-06 08:56发布

问题:

I'm reading the LESS official documentation (version 1.5) but I cannot understand how to import a reference to another CSS in order to use its content in my own file. For example:

mystyle.less

@import (reference) "bootstrap.min.css";
.mylabel {
    .label-success;
}

It shows this error: NameError: .label-success is undefined

Perhaps I misunderstand the documentation?

回答1:

You can only use reference with other LESS files. You cannot mix and match LESS and CSS files with that method.

If you need to use the mixins from Bootstrap, grab the Bootstrap LESS files.

Update: You can also specify the reference type, which should work for what you need:

@import (reference, less) "bootstrap.min.css";