Come on, for this you can use the border-left-width
and border-right-width
properties.
Here's a similar example you want:
.triangle {
width: 0;
height: 0;
border: 0 solid transparent;
border-left-width: 230px;
border-right-width: 242px;
border-top: 39px solid black;
}
<div class="triangle"></div>
Now we need to understand what's happening with div
and how the property works.
The border-left-width
and border-right-width
are the same, only the side that defines the size changes. Here is a small example of how they work:
.show-example {
/* Auxiliar */
background-color: black;
width: 20rem;
height: 5rem;
border: 0 solid #dc143c;
/* O que interessa */
border-right-width: 2em;
border-left-width: 2em;
}
<div class="show-example"></div>
Properties are the side width value, and work in partnership with border-top
, which will set the height of div
. Also remember that the values of the lateral width should be proportional, since the height is relative to the size of your triangle.
Note: The support for the triangle made with CSS is practically global, since we use well-known tags that are supported in almost all browsers, up to IE, from version 4 onwards.