How can I generate a diamond-shaped gradient?

81 views Asked by At

My goal is to create the follwing pattern:

diamond-shaped gradient

Can I generate this kind of gradient using only vanilla CSS?

I've seen this done in figma. However, there's only conic-gradient in CSS and no specific diamond-gradient.

1

There are 1 answers

0
Ruud Helderman On BEST ANSWER

You can achieve this effect by blending together two linear gradients, perpendicular to each other.

.diamond {
  background-blend-mode: multiply;
  background-image:
    linear-gradient(to left, #000, #0f0, #000),
    linear-gradient(to top, #000, #0f0, #000);
}

div {
  position: absolute;
  height: 200px;
  width: 200px;
  color: white;
}
<div class="diamond">Diamond gradient</div>