How do I calculate the maximum value of the border radius without using a percentage?
CSS3 uses an attribute border-radius
to set rounded corners on elements. Values ββare usually in px, and the minimum acceptable value is 0px. The visual result is variable, according to the dimensions of the element with this attribute. For example, an element with dimensions 100px X 100px border-radius: 20px;
will not be completely rounded (circle), otherwise it will be an element with dimensions 10px X 10px. The maximum allowable value is not limited.
Question: how to calculate the maximum value , according to the element size, to make it 100% rounded?
EDIT: How do I calculate the value in pixels (px)?
source to share
The right path must be
border-radius: 50%;
The spec states that you can use a percentage here, and it should come from the corresponding dimensions of the border-box
item.
The image from the spec shows why 50%
is the correct value if you want a circle:
If your element is not square (height! = Width), you can still use it to get a nice ellipse.
source to share