Can I ellipse a clipping mask on the bottom only?

前端 未结 1 1352
無奈伤痛
無奈伤痛 2020-12-30 17:50

I am trying to create a curved clipping mask on an image in CSS.

The curve is essentially just the bottom half of a very wide ellipse.

A requirement is that

相关标签:
1条回答
  • 2020-12-30 18:28

    Attempt 6: transparent :before with mega-border + overflow

    Issue: has fixed size but works so long as larger than site width/image height! Feels dirty though...

    Note: whilst the curves do not look equal, they are all accurate chunks of the same curvature/angle.

    div { position: relative; display: inline-block; overflow: hidden; }
    img { max-width: 100%; vertical-align: top; }
    
    div:before { 
      content: ""; 
      position: absolute; 
      bottom: -100px; 
      left: 50%; 
      margin-left: -900px;
      height: 1000px;
      width: 1600px;
      border-radius: 100%; 
      border: 100px solid #fff;
    }
    <div><img src="http://placehold.it/320x120" /></div>
    <div><img src="http://placehold.it/480x240" /></div>
    <div><img src="http://placehold.it/100x220" /></div>

    Hat-tip: http://jonmifsud.com/blog/inverse-border-radius-in-css/

    0 讨论(0)
提交回复
热议问题