M
M
McThinker2020-06-18 17:45:57
css
McThinker, 2020-06-18 17:45:57

Sass darken, lighten how to use correctly?

:root
  --mainColor: #28bebd
  --text-color: #FFF
  --mainColorHover: rgba(var(--mainColor), 0.5)

So I use it like this:
.btn-info
  background-color: var(--mainColor)
  border-color: var(--mainColor)

  &:hover, &:active, &:focus
    background-color: var(--mainColorHover)

But for some reason the color on hover does not work. lighten and darken with css variables, as I understand it, do not work. What's wrong with rgba?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Sharomet, 2020-06-18
@sharomet

Where is lighten or darken in your code?
$color: #112233;
$darkenColor: darken($color, 10%);
$lightenColor: lighten($color, 10%);

X
xenonhammer, 2020-06-18
@xenonhammer

$black: #000000
color: lighten($black, 10%)
color: darken($black, 10%)

R
radislaw, 2021-03-15
@radislaw

When you write: Css interprets it as: Now read the rgba documentation. Can this format be used? You need to rewrite the --mainColor property in a valid format for rgba:
--mainColorHover: rgba(var(--mainColor), 0.5)
--mainColorHover: rgba(#28bebd, 0.5)
--mainColor: 0, 0, 0 // или любой другой цвет rgb

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question