A
A
Alexey2015-11-05 12:21:38
css
Alexey, 2015-11-05 12:21:38

How in CSS, SCSS is better to specify colors?

1) Tell me how to correctly specify colors in SCSS, for example? Earlier I indicated in HEX, but they said that this is not correct, it is better to indicate in RGB. The question is why or maybe RGBA?
2) What is the best way to name variables in SCSS? For example $grey1, $grey2 - but I don't see much point in that, is it better in terms of content? For example $header-title? How do you indicate?
3) Is there a utility that could suggest that in this SCSS code, for example, certain pieces of code can be replaced with mixins or create, for example, a class that can be used to prevent code repetition?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail, 2015-11-05
@azovl

As for RGB or Hex, it’s more convenient for anyone, RGBA is sometimes useful, well, not always, it’s better to name variables, it’s logical if you have a theme, or just your layout, for example $bgHeader or $baseText, and are not tied to a specific color like $grey1, because in the future you can change the color and you have to change the variables.
My opinion is that it is better to use meaningful names that will not have to be changed in the future, otherwise your project will not be affected by changing them.

L
L0k1, 2015-11-05
@L0k1

Personally, I don't like the approach of naming colors by content. Well, I'll write $bgHeader - and then I need to use this color in the footer - and then this thing starts to annoy me footer {color: $bgHeader} ? any site has a color palette, let's say 10 colors, so I set them $ c_gray
, $c_gray_dark, $c_orange
And if you need to change the color from orange to blue, then any IDE supports refactoring
PS: Have you changed a lot completely color scheme to the opposite in the development process?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question