I am using CSS3 to build up random shapes. I am stuck on this Egg Shape. I checked upon the mathematics of Egg Shapes, which are composed by 2 circles with different radius. Yet I can't link this fundamental construction with the CSS buildup code here, especially the "border-radius" part.
#egg {
display:block;
background-color:green;
width:126px;
/* width has to be 70% of height */
/* could use width:70%; in a square container */
height:180px;
/* beware that Safari needs actual px for border radius (bug) */
-webkit-border-radius:63px 63px 63px 63px / 108px 108px 72px 72px;
/* fails in Safari, but overwrites in Chrome */
border-radius:50% 50% 50% 50%/60% 60% 40% 40%;
}
All you have to do is to change border-radius: 40px to border-radius: 50% .
CSS Syntaxborder-radius: 1-4 length|% / 1-4 length|%|initial|inherit; Note: The four values for each radius are given in the order top-left, top-right, bottom-right, bottom-left. If bottom-left is omitted it is the same as top-right. If bottom-right is omitted it is the same as top-left.
The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, or two radii to make elliptical corners.
5.1. Curve Radii: the ‘border-radius’ properties
The two length or percentage values of the ‘border-*-radius’ properties define the radii of a quarter ellipse that defines the shape of the corner of the outer border edge (see the diagram below). The first value is the horizontal radius, the second the vertical radius. If the second value is omitted it is copied from the first. If either length is zero, the corner is square, not rounded. Percentages for the horizontal radius refer to the width of the border box, whereas percentages for the vertical radius refer to the height of the border box. Negative values are not allowed.
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
.egg {
display: block;
width: 120px;
height: 180px;
background-color: green;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}
<div class="egg"></div>
Further reading on border radius with slash syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With