I want to import all styles from another less file, but into a limited scope. I'm trying this:
"my-site.less"
.wrapper-class { @import "path/to/styles.less"; }
But this doesn't work at all. I'm using the browser-based less.js option, and I can see the GET statement that is run when it actually does the import. But the resultant CSS does not contain any of the styles from the other sheet. If I do it like this, it works:
.wrapper-class { /* ... */ } @import "path/to/styles.less";
But this defeats the original purpose. So is there any way to do a limited-scope @import like this in Less? Thanks!
The @import rule is used to import one style sheet into another style sheet. This rule also support media queries so that the user can import the media-dependent style sheet. The @import rule must be declared at the top of the document after any @charset declaration.
The @import directive is used to import the files in the code. It spreads the LESS code over different files and allows to maintain the structure of code easily. You can put the @import statements anywhere in the code. For instance, you can import the file by using @import keyword as @import "file_name.
Since this question was posted and answered, pre-processors have implemented @import with scope. This now works in LESS, SASS and Stylus.
example:
.lt-ie9 { @import "ie8-fixes"; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With