How do I create a teardrop in HTML?

后端 未结 12 519
生来不讨喜
生来不讨喜 2020-12-02 03:59

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

12条回答
  •  渐次进展
    2020-12-02 04:26

    IMO this shape requires smooth curve-to beziers to ensure continuity of the curve.

    The Drop in question :

    For the drop in question,

    • smooth curves can't be used, as control points wont be of same length. But we still need to make the control points lie exactly opposite (180 deg) to the previous control points, to ensure full continuity of curve The picture given below illustrates this point :

    enter image description here
    Note: Red and blue curves are two different quadratic curves.

    • stroke-linejoin="miter", for the pointed top part.

    • AS this shape only uses successive c commands, we can omit it.

    Here's the final snippet:

    
      
    

    TBH though, accepted answer's curves are not quite continuous.


    For IE 5-8 (VML)

    Only works in IE 5-8. VML uses different commands than SVG. Eg. it uses v for relative cubic beziers.

    Note: This snippet won't run in IE 5-8 too. You need to create an html file and run it directly in the browser.

    
    
    
        
    
    
        

提交回复
热议问题