S
S
Sasha2022-04-04 17:57:32
Sass
Sasha, 2022-04-04 17:57:32

How to correctly specify the combination of the # symbol and color code?

Hello!

There is a piece of code like this

$blue:0378FA;//цвет указан БЕЗ #
@function color($color){
  @return #{'#'}$color;//в этом месте добавляем #
}
body{
  color:color($blue);//используем функцию
}


BUT a code execution error was detected, for example, if the color starts from 0, it will be ignored.
How to avoid it?
Perhaps there is an option to crop the variable (return everything from the 2nd position if the color is specified with #) ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Kit, 2022-04-06
@ShadowOfCasper

Have you tried that? Well, or so Maybe something will work, although I’m not sure Yes, by the way, it’s possible like and as you did, just through + connect Or maybe even like that
@return #{'#'}#{$color}
@return '#' + #{$color}
@return #{'#'}+$color
@return #{'#'} + #{$color}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question