<header class="header">
  <div class="header__title">
    <h1>
      <code>ellipse()</code>
    </h1>
  </div>
  <div class="header__reference">
    <ul class="reference-list">
      <li><a class="reference-list__link" href="https://developer.mozilla.org/en-US/docs/Web/CSS/basic-shape">MDN reference</a></li>
      <li><a class="reference-list__link" href="https://caniuse.com/#feat=css-clip-path">caniuse Support</a></li>
    </ul>
  </div>
</header>

<main>
  <div class="example">
    <p>
      In this example, we have an <code>img</code> element with a class of <code>ellipse</code> applied to it. A <code>clip-path</code> property is applied to the <code>ellipse</code> class, allowing us to create an oval. 
    </p>
    <p>
      The <code>ellipse()</code> function argument used for <code>clip-path</code> sets the oval's width and height to be <code>30vw</code> and <code>16vw</code>, respectively. This width and height radiates out from central point set to <code>50%</code> the image's width and <code>60%</code> the image's height.
    </p>

    <div class="example__demo example__demo--ellipse">
      <img 
        class="ellipse"
        alt="Jay Gatsby from the 2013 movie, The Great Gatsby, staring out at you, the viewwer and holding out a glass as a toast. Fireworks are exploding in the background. An ellipse effect has been applied, making the image an oval shape instead of a rectangle."
        src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/11907/great-gatsby-cheers.jpg" />
    </div>

    <p>
      Note that the padding around the image means the browser is still including the image's height and width when calculating its size. Here, it is rendering anything that does not have a mask applied to it as transparent instead of removing it from the rendered page.
    </p>
  </div>
</main>
// Demo
.ellipse {
  clip-path: ellipse(30vw 16vw at 50% 60%);
}


// Pen Setup
.example__demo--ellipse {
  background-color: var(--color-cinder);
  padding: 0;
  
  img {
    height: auto;
    width: 100%;
  }
}
View Compiled
Run Pen

External CSS

  1. https://codepen.io/ericwbailey/pen/vMXWgz.scss

External JavaScript

This Pen doesn't use any external JavaScript resources.