gpt4 book ai didi

html - 使用 CSS 的半椭圆形

转载 作者:技术小花猫 更新时间:2023-10-29 12:46:08 25 4
gpt4 key购买 nike

我正在尝试混合使用椭圆形和半圆形。

可以在 CSS 中创建半圆:

.halfCircle{
height:45px;
width:90px;
border-radius: 90px 90px 0 0;
-moz-border-radius: 90px 90px 0 0;
-webkit-border-radius: 90px 90px 0 0;
background:green;
}

椭圆可以这样制作:

.oval { 
background-color: #80C5A0;
width: 400px;
height: 200px;
margin: 100px auto 0px;
border-radius: 200px / 100px;
}

但是我怎样才能做出一个半椭圆形呢?到目前为止,这是我的尝试。发生的问题是我有平顶,发现 here .谢谢!

最佳答案

我已经用一种可能的解决方案更新了您的演示:

div {
background-color: #80C5A0;
width: 400px;
height: 100px;
border-radius: 50% / 100%;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
<div></div>

通过为 border-radius 使用基于百分比的单位,无论您的 widthheight 值如何,它都应该始终保持平滑的半椭圆.

经过一些小的改动,下面是将半椭圆垂直分成两半的方式:

div {
background-color: #80C5A0;
width: 400px;
height: 100px;
border-radius: 100% / 50%;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
<div></div>

关于html - 使用 CSS 的半椭圆形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17595147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com