I need to put a border with a gradient on a div like below, I’ve already tried a few methods but none of them work…
How can I do it?
Thanks in advance
The gradient is:
linear-gradient(93deg, #6FB3D9 -0.72%, rgba(217, 217, 217, 0.00) 98.53%, rgba(111, 179, 217, 0.00) 98.53%)
This is a screenshot from Figma
I’ve tried box-shadows, outline, border but none of them work, or I’ve used them wrong.
2
Answers
You can use
border-image
withlinear-gradient
In this case, to use the gradient in the border I see 2 ways, the first was commented on in a previous answer, which is using border-image.
Another way, which I don’t recommend, but is possible if you have a problem using the border-image with another tag or in cases like a form, is to define a background-image on a top element and create a child for that element with the desired color. The gradient styling can be done entirely on the parent using the ::before pseudo-element.
Referências: