How do I create a shape like this to display on a webpage?
I don't want to use images since they would get blurry on scaling
I tried with CSS:
.tear {
display: inline-block;
transform: rotate(-30deg);
border: 5px solid green;
width: 50px;
height: 100px;
border-top-left-radius: 50%;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
}
<div class="tear">
</div>
That turned out really screwed.
And then I tried with SVG:
<svg viewBox="0 100 100">
<polygon points="50,0 100,70 50,100 0,70"/>
</svg>
It did get the shape, but the bottom part wasn't curved.
Is there a way to create this shape so it can be used in an HTML page?
SVG approach:
You can achieve the double curve easily with an inline SVG and the
<path/>
element instead of the<polygon/>
element which doesn't allow curved shapes.The following example uses the
<path/>
element with:Q
)A
)SVG is a great tool to make this kind of shapes with double curves. You can check this post about double curves with an SVG/CSS comparison. Some of the advantages of using SVG in this case are:
Browser support for inline SVG goes back to Internet Explorer 9. See canIuse for more information.