Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between border-radius 50% and 100%?

Tags:

html

css

border

I just found that border-radius: 50% and border-radius: 100% look the same.

Does anyone have an explanation on that?

like image 545
Saif Avatar asked Mar 29 '19 04:03

Saif


People also ask

What is the best border radius?

3–4px Radius: This is best and probably the most safe choice. 3–4px is in every point of standard across multi fields, expressing a little bit more friendly and accommodating then 0px.

How do you find the border radius of a percentage?

Percentages: Refer to corresponding dimension of the border box. So border-radius:50%; defines the raddi of the ellipse this way : the radii on the X axis is 50% of the containers width. the radii on the Y axis is 50% of the containers height.

What is the difference between border and border radius?

The only difference between them is the right button has a radius of 5px applied. As with borders, radius allows you to set different properties for each side of the element using the toggle controls.

What does border radius mean?

The border-radius CSS property rounds the corners of an element's outer border edge.


2 Answers

You’ll notice a difference if you round each corner individually. 100% rounds 100% of each edge, 50% only 50% of each edge. If the corner is to be rounded by a radius that is too large for any given edge, then the effective radius will be smaller.

Consider this example:

div{
  display: inline-block;
  vertical-align: middle;
  background: rebeccapurple;
  border: 1px solid black;
  width: 100px;
  height: 100px;
  margin-bottom: 10px;
}
code{
  display: inline-block;
  vertical-align: middle;
  margin-left: 20px;
  padding: 3px;
  background: #eee;
}

.half{
  border-top-right-radius: 50%;
}
.full{
  border-top-right-radius: 100%;
}
.weird{
  border-top-left-radius: 50%;
  border-top-right-radius: 100%;
}
<div class="half"></div><code>border-top-right-radius: 50%;</code><br/>
<div class="full"></div><code>border-top-right-radius: 100%;</code><br/>
<div class="weird"></div><code>border-top-left-radius: 50%;<br/>border-top-right-radius: 100%;</code>
like image 155
Sebastian Simon Avatar answered Oct 19 '22 11:10

Sebastian Simon


Anything more than the radius defaults to the actual radius. By definition a radius is the same in all directions, defining a circle. In other words, half of the diameter. 50%.

That means that anything above the radius (a radius is half, so 50%) defaults to the radius. So the browser thinks of anything above 50% as simply 50%, and will have the same effect.

I found this here.

like image 30
Aniket G Avatar answered Oct 19 '22 11:10

Aniket G