html - CSS3 Border-radius 创建一个蛋形

标签 html css css-shapes

我正在使用 CSS3 构建随机形状。我被困在这个蛋形上。我检查了蛋形的数学,它由 2 个不同半径的圆组成。然而,我无法将此基本结构与此处的 CSS 构建代码联系起来,尤其是“border-radius”部分。

#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%;
}

最佳答案

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%;

enter image description here

.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在边界半径上使用斜杠语法。

关于html - CSS3 Border-radius 创建一个蛋形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18796538/

相关文章:

html - 如何在不使用任何框架的情况下访问以表单提交的数据,该数据用nodejs保存为另一个文件

jquery - 带有 div 和幻灯片可变秒数的轮播循环

javascript - 如何在同一行对齐 span 和 html 下拉列表?

html - 如何使突出显示链接符合 CSS 形状

html - 使用 CSS3 自定义形状和动画

html - CSS 背景图像与选择器的高度/宽度不匹配?

css - 双曲线形状

css - 重叠三 Angular 形

html - 设计 Select 标签字体样式

html - 为什么黑莓手机的 td 中没有正确的填充