Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrong number of arguments (4 for 3) for `rgb' issue in css.scss file in rails 3.2.13

rgb wrong number of arguments issue in rails:

I saw that rgb in css file takes 3 arguments as mentioned here

http://www.w3schools.com/cssref/css_colors.asp

But in my project abc.css.scss file have code like this

border: 1px solid rgb(100, 100, 100, 2);
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 3px 2px rgba(67, 67, 67, 0.1);
-moz-box-shadow: 0px 3px 2px rgba(67, 67, 67, 0.1);

So what is happening here. Am I missing something?

Thanks in Advance!

like image 728
Taimoor Changaiz Avatar asked May 16 '13 07:05

Taimoor Changaiz


2 Answers

The short and sweet answer is when you use rgb you can't pass an alpha property. Use rgba to use alpha

like image 113
user2465134 Avatar answered Sep 30 '22 16:09

user2465134


The answer is quite self explanatory. rgb expects 3 arguments, so you need to give it 3, not 4.

This is what you want:

border: 1px solid rgb(100, 100, 100);
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 3px 2px rgba(67, 67, 67, 0.1);
-moz-box-shadow: 0px 3px 2px rgba(67, 67, 67, 0.1);

Notice that the first line has changed

If you keep the 4th parameter, that first line of code will not work. It will simply be ignored and have no effect.

See this example: You will notice the square is black, because the rgb with the 4th parameter is invalid and is therefore not applied

like image 37
musefan Avatar answered Sep 30 '22 17:09

musefan