如果我对border-radius 使用像素或em值,则边缘半径始终为圆弧或药丸形状,即使该值大于元素的最大边.
当我使用百分比时,边缘半径是椭圆形的,从元素每边的中间开始,形成椭圆形或椭圆形:
border-radius的像素值:
div {
background: teal;
border-radius: 999px;
width: 230px;
height: 100px;
padding: 40px 10px;
box-sizing: border-box;
font-family: courier;
color: #fff;
}
Run Code Online (Sandbox Code Playgroud)
<div>border-radius:999px;</div>
Run Code Online (Sandbox Code Playgroud)
border-radius的百分比值:
div {
background: teal;
border-radius: 50%;
width: 230px;
height: 100px;
padding:40px 10px;
box-sizing:border-box;
font-family:courier;
color:#fff;
}
Run Code Online (Sandbox Code Playgroud)
<div>border-radius:50%;</div>
Run Code Online (Sandbox Code Playgroud)
为什么边界半径百分比的作用方式与使用像素值或em值设置的border-radius的作用方式相同?
我想在我的网站上有一个百分比圈指示符:
在这种情况下,它显示75%.该怎么做?我在图像文件中有黄色圆圈,但是如果它更容易,有些如何,使用CSS完成所有操作,这对我来说没问题.