Sergey
Sergey

Reputation: 5476

Is it possible to convert rgba color to hex using 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.

Upvotes: 5

Views: 745

Answers (1)

seven-phases-max
seven-phases-max

Reputation: 11820

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))

Upvotes: 2

Related Questions