How can I use Bootstrap styles in a LESS file?

我的未来我决定 提交于 2019-12-03 17:09:41
Bass Jobsen

1) You should prefer to download Bootstrap's LESS files and import them with @import "bootstrap.less". If you can't follow @seven-phases-max 's links and use @import (less) bootstrap.min.css

2) "// ...can't find the source of the "@screen" at-rules:" these rules are not defined in Bootstrap's LESS files. The code from the docs illustrate the boundaries of the grid defined by Bootstrap. It will show you what happens if you change the variables mentioned.

For example take a look to grid.less which defines:

@media (min-width: @screen-sm) { width: @container-sm; }

Also read: http://blog.scur.pl/2012/06/variable-media-queries-less-css/ and LESS variables in @media queries i don't think you solution won't work cause:

@screen-lg: 992px;
@large: ~"screen and (min-width: @screen-lg)";
@media @large{ color: red; }

compiles to:

@media screen and (min-width: @screen-lg) {
  color: red;
}

NB @screen-lg not set.

3) " .hide // compile error" there is no mixins called hide You could use mixins from responsive-utilities.less (see also: http://getbootstrap.com/css/#responsive-utilities)

In your case you will get something like:

//example DO NOT compile to useful CSS
@import (reference) "bootstrap.less";
#linkedin-flair
{
&:extend(.hidden-xs);
&:extend(.hidden-sm);
}

4) " .col-sm-4 // compile error" .col-sm-4 is dynamical generate (grid.less) you can't use it as a mixin.

use:

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