Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to convert rgba color to hex using LESS

Tags:

css

less

I have an element(<div>) with transparent background color: rgba(96, 96, 96, .1) and I assume my element has a wrapper with white background.

Is there any way to convert transparent color to hex using LESS css? For example, rgba(96, 96, 96, .1) should be equal to #efefef.

I've read the color function article, but have not found a suitable answer.

like image 543
Sergey Avatar asked Oct 31 '22 06:10

Sergey


1 Answers

If I understand the question correctly you're looking for a function that calculates result of compositing/layering of one color (e.g. rgba(96, 96, 96, .1)) with/over another (e.g. white). In Less it's supposed to be one of the blending functions family, but since the name of such function in current naming convention has to be normal (which is rather weird) this function is not included. But if one of colors is always white you still can get the desired result via multiply:

multiply(white, rgba(96, 96, 96, .1))
like image 72
seven-phases-max Avatar answered Nov 09 '22 11:11

seven-phases-max