-
Notifications
You must be signed in to change notification settings - Fork 0
/
rgbas.scss
44 lines (42 loc) · 1.15 KB
/
rgbas.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Provides support for rgba color also for old Internet Explorer versions (>=6; <=8)
@mixin background-color-rgba($fullColor) {
$r: red($fullColor);
$g: green($fullColor);
$b: blue($fullColor);
$a: round((alpha($fullColor))*255);
$argbHex: decToHex($a)+decToHex($r)+decToHex($g)+decToHex($b);
$msFilter: quote("progid:DXImageTransform.Microsoft.gradient(startColorstr=#"+$argbHex+", endColorstr=#"+$argbHex+")");
// Web browsers that does not support RGBa
background: rgb($r, $g, $b);
// IE9 and modern browsers
background: $fullColor;
.ie8 &, .ie7 &, .ie6 & {
background: none;
-ms-filter: $msFilter;
filter: unquote($msFilter);
zoom: 1;
width: 100%;
}
}
@function decToHex($d) {
$hexVals: "A" "B" "C" "D" "E" "F";
$base: 16;
$quotient: $d;
$result: "";
@if $d == 0 {
$result: "00";
}
@while $quotient != 0 {
$mod: $quotient % $base;
$quotient: floor($quotient / $base);
@if $mod > 9 {
$mod: nth($hexVals, $mod - 9);
}
@if $d < $base {
$result: "0" + $mod;
} @else {
$result: $mod + $result;
}
}
@return $result;
}