Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make a rounded triangle with just CSS?

I'm trying to make the following shape with just CSS:

Rounded Triange

Here is what I currently have:

.triangle {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 56px 56px 0 0;
  border-color: #ff4369 transparent transparent transparent;
}
<div class="triangle">
</div>

I'm unable to use border radius to make the top-left corner rounded... Is there another way to do this or do I need to use an SVG?

like image 787
AnApprentice Avatar asked Apr 22 '18 18:04

AnApprentice


People also ask

How do I create a rounded triangle in CSS?

Method 1. If you want to generate a triangle with rounded corners, the code is at least , and the best way is to use SVG to generate it. Use SVG's polygon tag <polygon> generate a triangle, and use SVG's stroke-linejoin="round" generate rounded corners at the connection.

How do I create a curved container in CSS?

To create a rounded corner, we use the CSS border-radius property. This property is used to set the border-radius of element.


1 Answers

Yes it's possible using border-radius:

.triangle {
  box-sizing: border-box;
  width: 60px;
  height: 60px;
  border-top: solid 30px rgb(200,30,50);
  border-left: solid 30px rgb(200,30,50);
  border-top-left-radius: 12px;
  border-right: solid 30px transparent;
  border-bottom: solid 30px transparent;
}
<div class="triangle triangle-0"></div>
like image 186
ashfaq.p Avatar answered Nov 15 '22 09:11

ashfaq.p