less

Can less.js read class names and parameters from HTML?

余生颓废 提交于 2019-11-28 02:28:40
I've just started using LESS and I love it. I'm now looking into grid.less which creates grids using LESS semantics. This enables me to do something like this //css .mydiv { .column(9); } //html <div class="mydiv"> 9 column wide</div> I've not studied less.js , but is there somehow possible to do the following: //html <div class="column(9)"> 9 column wide</div> Is there any way to achieve this? LESS cannot easily read a parameter from the HTML, as LESS is a preprocessor (it processes the CSS before anything is presented in HTML). However, you can prebuild classes that will essentially do the

How to keep duplicate properties in compiled CSS file when use LESS?

青春壹個敷衍的年華 提交于 2019-11-28 02:22:38
LESS code .foo { background-size: 200px; //for old browsers background-size: cover; } CSS expected .foo { background-size: 200px; background-size: cover; } but less.js remove the first background-size property in compiled CSS file. AS already pointed out by @seven-phases-max clean-css removes these properties. Notice that the --advanced has been set by default. You should use the --skip-advanced option to prevent your double properties from being removed. According to https://github.com/less/less-plugin-clean-css the advanced option has been set to false by default. lessc foo.less outputs:

Extending Bootstrap 3 LESS .btn-group not working

谁说胖子不能爱 提交于 2019-11-28 02:21:21
Ultimately I'm trying to accomplish the following styles with LESS. <div class="filter btn-group"> <button class="btn btn-default" type="button" data-filter="*">show all</button> <button class="btn btn-default" type="button" data-filter=".cd">CD</button> <button class="btn btn-default" type="button" data-filter=".vinyl">Vinyl</button> </div> I have the following HTML <div class="filter"> <button type="button" data-filter="*">show all</button> <button type="button" data-filter=".cd">CD</button> <button type="button" data-filter=".vinyl">Vinyl</button> </div> And I have this in a LESS file with

How to override a LESS mixin variable based on a parent's variable

半城伤御伤魂 提交于 2019-11-28 02:21:19
I am a newbie, so be gentle. I am sure my terminology is incorrect too: suppose I have my own jumbotron override: .jumbotron { background-color: #ff4400; } and then I want to have a custom override of that where I inherit the above class and only override its background color using its color as a parameter to "lighten()". I can't figure out the syntax: .Myjumbotron { .jumbotron; /* not sure what goes below for "parent.background-color" */ background-color: lighten(parent.background-color, 30%); } Harry LESS allows you to define variables. So you can define a variable for the parent's color and

LESS transition mixin with prefixes

我与影子孤独终老i 提交于 2019-11-28 02:20:17
I was wondering if it's possible to create a LESS mixin that I could use like this: .transform(transition, .5s, ease-out); and has this CSS as output: -webkit-transition: -webkit-transform .5s ease-out; -moz-transition: -moz-transform .5s ease-out; transition: transform .5s ease-out; but I would also be able to use the same mixin for other properties (i.e. .transition(opacity, .5s) should output to -webkit-transition:opacity .5s; -moz-transition:opacity .5s; transition:opacity .5s; Thanks! Leon Since Less version 2 you can use the autoprefix postprocessor plugin and the consensus is that you

Parent Selector nested inside &:hover

余生长醉 提交于 2019-11-28 02:19:58
I am using the Less parent selector to shorten my selectors: .module-name { // styles go here &__sub-module-1 { //styles go here } } Now my problem is how to continue to use the parent selector for adding the module-name inside a nested :hover statement. E.g. on hover of sub-module-1 I want to change something in sub-module-2. Inside the &:hover statement, what does the parent selector refer to? .module-name { &__sub-module1 { &:hover { &__sub-module2 { // on hover of .module-name__sub-module1 change something in .module-name__sub-module2 } } } } If i write it like this it works, but it

Bootstrap 3 mixin multiple make-*-column

旧城冷巷雨未停 提交于 2019-11-28 02:07:04
I'm using an specific mixin trying to make my code more clear. So instead of using: <div class="col-lg-3 col-md-5 col-sm-6 col-xs-12"> I'm using: <div class="stackOverflowRocksIt"> and in my mixins.less: .stackOverflowRocksIt{ .make-lg-column(3); .make-md-column(4); .make-sm-column(6); .make-xs-column(12); } It works properly with XS and SM viewports, but not when I resize to MD or LG (then is taking the SM size). Is this the proper way to create columns for different viewports sizes? Any idea? You should re-order your mixin calls: .stackOverflowRocksIt { .make-xs-column(12); .make-sm-column(6

How to exend the Less compiler with a custom function leveraging a plugin

跟風遠走 提交于 2019-11-28 01:27:58
Since version 2 of Less you can use plugins . You can also use these plugins to add custom function to Less, examples: https://github.com/less/less-plugin-advanced-color-functions/ and https://github.com/bassjobsen/less-plugin-cubehelix Inspired on https://github.com/less/less.js/issues/2341 i want to add a custom function twotimesandten to less, so that: @start: 10; .test { result: twotimesandten(@start); } compiles into: .test { result: 30; } After reading http://lesscss.org/usage/#plugins-for-plugin-authors , i wonder how to do this? First write the plugin for usage in the browser . You

Using class set in media query as mixin in less

北慕城南 提交于 2019-11-28 01:09:15
问题 I am trying to reuse a set of classes set inside a media query as mixins to use throughout a website instead of embedding un-semantic class names in html. Here is an example of my problem. @media (min-width: 1000px) { .foo{width:120px;} .foo-2{width:150px;} } @media (max-width: 999px) { .foo{width:110px;} .foo-2{width:120px;} } .bar{.foo;} .bar-2{.foo;} .bar-3{.foo-2;} the .bar-X will never get any styles applied. I can guess that this is happening because LESS doesn't create .bar-X inside

LESS files in Visual Studio not syntax highlighted

心不动则不痛 提交于 2019-11-28 01:00:35
问题 I have just installed Web Essentials 2012 for VS2012, but when I open a .less file, nothing is highlighted and the preview window doesn't display. Are there any settings or something I am missing to make this work? 回答1: Web Essentials does not include Less tools anymore, you need to install the ASP.NET and Web Tools 2012.2 update to work with Less. A bit more details can be found on Web Essential's developer's blog. 来源: https://stackoverflow.com/questions/15323250/less-files-in-visual-studio