Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error in CSS with `rgb(0 0 0 / 15%)`

Tags:

css

I was inspecting the codecademy.com site and there is an element with the attribute:

box-shadow: inset 0 0 5px rgb(0 0 0 / 15%), 0 0 7px #fff; 

It seems that this causes a double circle around the element, the inner circle being white and the outer one transparent.

However, when I try to use this code in my stylesheet, I get the following error:

Error: Function rgb is missing argument $green.         on line 1260 of common.scss >>                 box-shadow: inset 0 0 5px rgb(0 0 0 / 15%), 0 0 7px #fff;    ------------------------------------------^ 

Not sure what this error is about or how to resolve it. Any ideas?

like image 947
Wesley Avatar asked Mar 26 '21 23:03

Wesley


People also ask

How do I pass a RGB color in CSS?

CSS rgb() Function The rgb() function define colors using the Red-green-blue (RGB) model. An RGB color value is specified with: rgb(red, green, blue). Each parameter defines the intensity of that color and can be an integer between 0 and 255 or a percentage value (from 0% to 100%).

Can you use RGB in CSS?

The CSS rgb() function can be used to provide a color value when using CSS. It allows you to specify an RGB color value by specifying the red, green, and blue channels directly. RGB (which stands for Red, Green, Blue) is a color model in which red, green and blue light can be added together to reproduce a color.


2 Answers

As Dan Mulin stated, sass hasn't yet caught up to the new standard so instead of box-shadow: inset 0 0 5px rgb(0 0 0 / 15%) use box-shadow: inset 0 0 5px rgba(0, 0, 0 , 0.15) Regards

like image 93
Michael Kiarie Avatar answered Sep 29 '22 04:09

Michael Kiarie


The new standard is to use three values without commas followed by a slash and the opacity as a percentage. Which looks like this:

/* New Standard for color using rgb (rgba depreacated) */ rgb(0 0 0 / 0%)  /* Old standard for color using rgb and rgba */ rgb(0, 0, 0)  rgba(0, 0, 0, 0) 

Sass hasn't caught up to the standard, so you'll get a compilation error when you try to use the new format.

You can learn more here: https://drafts.csswg.org/css-color/#rgb-functions

like image 27
Dan Mullin Avatar answered Sep 29 '22 04:09

Dan Mullin