Better color coercion

mkoistinen's Avatar


18 Jan, 2011 08:19 PM

Would love it if I could do this:

.gradient( @color1, @color2 ) {
    @black = #000000;
    @hex1 = @black + @color1;
    @hex2 = @black + @color2;

    // Rest of the gradient styles here and I can use
    // @color1 for webkit and moz, etc. and @hex1 for
    // IE's filter arguments, as it would choke on
    // anything else.

To be honest, the docs page eludes to this being a possibility, but I only get errors about something not having a toColor() method.

  1. 1 Posted by Dale Sande on 25 May, 2011 09:25 PM

    Dale Sande's Avatar

    I believe that this is a syntax you can use.

    .gradient( @color1, @color2 ) {

    @black: #000000;
    @hex1: @black + @color1;
    @hex2: @black + @color2;


  2. 2 Posted by Dale Sande on 25 May, 2011 09:28 PM

    Dale Sande's Avatar

    Also, your IE choke? Dunno what you are doing to create gradients, but here has what I have set up for a series of mixins to use in a project.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac