I recently had a strange problem after updating SASS. I have a modal dialog with a semi-transparent overlay behind it. For modern browsers, I'm using a CSS transition from
to rgba(0,0,0,0)
rgba(0,0,0,.5)
For older browsers (namely IE8), I'm using some JavaScript to apply the transparency and animate the transition. To make sure the background gets set correctly, I'm using the standard fallback strategy of defining the background as background: rgb(0,0,0);
right before the rgba
line.
This worked fine, until SASS optimized my code by changing
to background: rgba(0,0,0,0);
background: transparent;
The reason? It's 2 characters shorter. Yes, we've now saved 2 bytes of easily compressible text in exchange for breaking my code.
Why did it break? Well, if you haven't already figured it out, normally a browser that doesn't support rgba
will simply skip that property and move on. But transparent
is supported. So now, instead of having a black background that I would later animate the opacity, I'm animating the opacity of a transparent background.
To fix this, I simply forced SASS to output the exact text I wanted.
It's not ideal, and I probably could have changed my code so that I didn't have to be in this situation at all. But this was the quickest, most straightforward solution.
#{rgba(0,0,0,0);}
Comments
Post a Comment