Search code examples
csssasscompass-sasscompass

how to stop compass for converting rgba format to hex format


I need colors in rgba format for my css file. So i wrote colors in my scss file in rgba format. When i complied all colors converted into their Hex code in css file, if their opacity is 1 else same rgba format is being used.

For example

SCSS File
background: rgba(61,61,61,1);

Complied Css
background: #3d3d3d; 

If opacity is ,suppose 0.5

SCSS File
background: rgba(61,61,61,0.5);

Complied Css
background: rgba(61,61,61,0.5);

How to stop conversion for all rgba format. Any suggestion would be appreciated.


Solution

  • Sass will preserve the format of your color... unless it is in something other than the keyword, hex, or rgba formats. If you want to absolute format, then you have to turn into string For example : - In scss variable file

    $mercury-grey: #{'rgba(230, 230, 230, 1)'};

    Input
    
    .class {
        color: $mercury-grey;
    }
    
    Output:-
    .class {
        color: rgba(230, 230, 230, 1);
    }