Can a LESS CSS pseudo-class pass an attribute of the selector to a function? -
i'm trying create single point of definition gradients in less css. i've created function writes cross-browser css code me, there's 1 issue can't solve.
i specify gradients once , have seperate function (that listens argument "flip") swap 2 color variables on hover. i've posted example below:
selector { .background-gradient(rgba(27, 117, 185, .35), 48%, rgba(22, 97, 154, .35), 52%); } selector:hover { .background-gradient(flip); }
i've been looking solution but, of course, found nothing. sum things up: i'd have function reads selector's gradient values , uses them create hover style swapping colors. hope it's possible.
thanks in advance!
ps: creating function listens "flip" (pattern-matching) not problem, thought give better idea of i'm trying achieve.
its not 100% clear want, why not have this
.selector { @startcol: rgba(27, 117, 185, .35); @startpercentage: 48%; @endcol: rgba(22, 97, 154, .35) @endpercentage: 52%; .gradient(@startcol, @startpercentage, @endcol, @endpercentage); &:hover { .gradient(@endcol, @endpercentage, @startcol, @startpercentage); } }
if common flip on hover make above mixin , have call once per class/gradient definition.
there no way mixin know arguments passed function or call mixin array of values.
Comments
Post a Comment