Creating a triangle in css with a gradient background

后端 未结 3 1183
闹比i
闹比i 2021-01-05 13:24

I am trying to create a triangle in css with a gradient background. I have not had any success as yet. Is there way to do this to bring off this effect seen in the image bel

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-05 13:54

    You can create a CSS triangle, but not a CSS triangle that is itself a gradient. The only trick I would suggest is to pick a color that most resembles the color within the gradient background. It just depends on how big your gradient actually is, and how well the triangle will blend in.

    For the red div, you could try using the color #d94040, but then it will lack a border and a drop shadow. However, these can be added. To add a border to a CSS triangle, you can place a inside your that is also a CSS triangle that is the same size. TThis would require using absolute positioning and z-index to overlap them.

    Or you can use ::after or ::before to create your CSS triangles without the added HTML code, but then that would only work in modern browsers only.

提交回复
热议问题