less-mixins

Can I define a LESS mixin to generate a transition-property with a variable number of parameters?

风格不统一 提交于 2019-11-27 13:58:59
问题 I'm introducing LESS to a large web app project to simplify my CSS. I've got a few CSS rules which apply transitions to a varying number of properties, for example: .movable { transition-property: top, left; transition-duration: 0.2s; transition-timing-function: ease; } .fadeAndStretchable { transition-property: opacity, width, height, margin; transition-duration: 1.5s; transition-timing-function: ease-out; } (Note: I've omitted -webkit , -moz and -o properties here for brevity: in reality

Multiple properties are getting treated as separate arguments in mixins

主宰稳场 提交于 2019-11-27 13:37:48
I'm trying to write a mixin, but I can't seem to get the arguments working the way I want: multiple properties are getting treated each as a separate argument. Current Code .transition(@property: all, @time: 1s, @timing: ease-in-out) { -moz-transition: @property @time @timing; -webkit-transition: @property @time @timing; -o-transition: @property @time @timing; transition: @property @time @timing; } a { .transition(color, opacity, .5s); } Desired Output a { -moz-transition: color, opacity .5s ease-in-out; -webkit-transition: color, opacity .5s ease-in-out; -o-transition: color, opacity .5s ease

Using undefined number of arguments in mixins

99封情书 提交于 2019-11-27 08:11:43
问题 I currently have -webkit specific attributes in my Less CSS sheet, I am trying to update them with mixins to add -moz attributes, like this: .transition(@1) { -webkit-transition: @1; -moz-transition: @1; } div { .transition(all .5s); } The example above works fine, however I also have things like that: div { -webkit-transition: border-color .3s, background .3s; } And I can’t call the mixin as .transition(border-color .3s, background .3s) because it has more arguments than defined in the mixin

How do I extend a class/mixin which has dynamically formed selector

帅比萌擦擦* 提交于 2019-11-27 05:37:19
How do I extend a Less class which is dynamically formed using & combinator? Less which generates expected output: .hello-world { color: red; } .foo { &:extend(.hello-world); font-size: 20px; } Expected CSS output: .hello-world, .foo { color: red; } .foo { font-size: 20px; } Less does not generate expected output: .hello { &-world { color: red; } } .foo { &:extend(.hello-world); font-size: 20px; } Unexpected CSS output: .hello-world { color: red; } .foo { font-size: 20px; } Extending a dynamically formed selector (loosely using the term) like that is currently not possible in Less. There is an

Less CSS: Mixins with Variable Number of Arguments

雨燕双飞 提交于 2019-11-27 04:29:40
LESS allows parametric mixins, such as: .transition(@property, @duration){ transition: @property @duration; -moz-transition: @property @duration; /* Firefox 4 */ -webkit-transition: @property @duration; /* Safari and Chrome */ -o-transition: @property @duration; /* Opera */ } However, this doesn't always work with properties such as transitions. If you are trying to have multiple transitions and attempt to call the mixin multiple times, the last mixin overrides all previously defined transitions. That's because the proper CSS3 syntax for defining multiple transitions is: ... { transition:

Multiple properties are getting treated as separate arguments in mixins

元气小坏坏 提交于 2019-11-26 16:25:23
问题 I'm trying to write a mixin, but I can't seem to get the arguments working the way I want: multiple properties are getting treated each as a separate argument. Current Code .transition(@property: all, @time: 1s, @timing: ease-in-out) { -moz-transition: @property @time @timing; -webkit-transition: @property @time @timing; -o-transition: @property @time @timing; transition: @property @time @timing; } a { .transition(color, opacity, .5s); } Desired Output a { -moz-transition: color, opacity .5s

How do I extend a class/mixin which has dynamically formed selector

拥有回忆 提交于 2019-11-26 11:38:44
问题 How do I extend a Less class which is dynamically formed using & combinator? Less which generates expected output: .hello-world { color: red; } .foo { &:extend(.hello-world); font-size: 20px; } Expected CSS output: .hello-world, .foo { color: red; } .foo { font-size: 20px; } Less does not generate expected output: .hello { &-world { color: red; } } .foo { &:extend(.hello-world); font-size: 20px; } Unexpected CSS output: .hello-world { color: red; } .foo { font-size: 20px; } 回答1: Extending a

Less CSS: Mixins with Variable Number of Arguments

可紊 提交于 2019-11-26 11:09:07
问题 LESS allows parametric mixins, such as: .transition(@property, @duration){ transition: @property @duration; -moz-transition: @property @duration; /* Firefox 4 */ -webkit-transition: @property @duration; /* Safari and Chrome */ -o-transition: @property @duration; /* Opera */ } However, this doesn\'t always work with properties such as transitions. If you are trying to have multiple transitions and attempt to call the mixin multiple times, the last mixin overrides all previously defined