question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rgba(#hex, 1) compiles to hex again

See original GitHub issue

sass versions tested: 3.2.19 and 3.4.12

compiling error

background: rgba(#cccccc, 1)

compiles to

background: #cccccc;

workaround:

background: rgba(#cccccc, 0.999999)

compiles to the desired

background: rgba(204, 204, 204, 1.0);

important for e.g. inline-svgs in FF

Even though it makes no difference for the usual background the rgba() value is important when it comes to colors inside a path in inline-svgs (e.g. Firefox can only handle rgb/rgba there).

Also when I ask for a rgba value I expect to get a rgba value, no matter what. 😃

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
cimmanoncommented, Feb 17, 2015

Sass tries to maximize browser compatibility when it comes to colors, so your only choice is to create a function specifically for this.

@function safe-rgba($color, $alpha: 1.0) {
    @return unquote("rgba(#{red($color)}, #{green($color)}, #{blue($color)}, #{$alpha})");
}

.foo {
  background: safe-rgba(red);
}

Output:

.foo {
  background: rgba(255, 0, 0, 1);
}
0reactions
tatzecommented, Feb 22, 2015

@cimmanon buärks! Thanks! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

LESS Compiler Converts RGBA() to Hex - css - Stack Overflow
LESS' rgba() function takes a percentage between 0% and 100% . You're passing 128 , which is fully opaque.
Read more >
RGBA to HEX Converter - Simple CSS Media Query Generator
Use our simple tool below to convert your RGBA (R, G, B, A) color to a Hex Color CSS code. It's not lazy,...
Read more >
Color Formats in CSS - hex, rgb, hsl, lab - Josh W Comeau
Introduction. CSS has a whole slew of different color formats: hex codes, rgb(), hsl(), lch(), the list goes on! Which one should we...
Read more >
From Hex to Color and Back in SwiftUI - Marco Eidinger
From Color to Hex in SwiftUI​​ This includes colors you create from a Core Graphics color, from RGB or HSB components, or from...
Read more >
8-Digit Hex Codes? | CSS-Tricks
The formats are sometimes referred to as #RRGGBBAA and #RGBA. The AA part is a hex representation of 0-100 is like: 0 =...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found