0

I´m working on a website with a CMS tool. I want to change the background of an image preview, which is in css code this:

.mfp-container {
background: rgb(222, 222, 222);
}

So it's a really basic code, I just want to adjust the color. My CMS Tool works with css variables and I never worked with those and really have no idea how to get a variable out of this.

Does someone know how to get one out of this basic code? Or is there any formula to "convert" it?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Vogtei
  • 13
  • 5
  • If I'm understanding you correctly, that's not how CSS vars work. However if you just want to change the background and `mfp-container` is the selector you're given then you can just override with your own css like `.mfp-container { background: red !important }` – Chris W. Jan 11 '22 at 22:24
  • You want to permanently create a CSS variable out of the RGB color value and then call it? Or were you under the impression that `rgb(222, 222, 222)` *was* a variable. – TylerH Jan 11 '22 at 22:39
  • Does this answer your question? [How can I define colors as variables in CSS?](https://stackoverflow.com/questions/1875852/how-can-i-define-colors-as-variables-in-css) – sallf Jan 11 '22 at 22:50

1 Answers1

0

https://www.w3schools.com/colors/colors_rgb.asp

It's RGB colour code, so you just enter wanted amount of red 0-255, green 0-255, blue 0-255 separated by commas

To use this color as variable you would declare it like this:

--variable-name:rgb(222,222,222)

And then use it later in CSS like this

background:var(--variable-name)
rmbdeivis
  • 47
  • 4