LESS Mixins aren't available in other imported LESS files

北慕城南 提交于 2020-01-06 11:16:12

问题


I have this code:

@import "vars.less";

// Desktop/Laptop Section
@import "mixins-d-1.less";
@import "positioning.less";
@import "containers-d-1.less";

Inside containers-d-1.less I reference a mixin from mixins-d-1.less. However, I get an error saying that it's undefined.

I'm able to pull my variables out of vars.less, why can't I pull my mixins out of mixins-d-1.less?


回答1:


The problem wasn't the importing at all, really.

I made a mistake in how I was using media queries.

Both files had the same media query since they were both for the desktop CSS (hence the "d"). However, the second one, in containers-d-1.less was OVERWRITING the first one and blowing away all my mixins! I clearly need to wrap the import block in a single media query for that section instead of redeclaring it inside each less file.



来源:https://stackoverflow.com/questions/53233211/less-mixins-arent-available-in-other-imported-less-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!