如何计算边界半径的最大值而不使用百分比? [英] How to calculate the maximum value for a border-radius without using percentage?
问题描述
CSS3使用 border-radius
属性在元素中设置圆角。这些值通常在 px 中设置,允许的最小值为 0px 。视觉结果是可变的,根据具有此属性的元素的尺寸。例如,尺寸 100px X 100px 且 border-radius:20px;
的元素将不会完全舍入(圆形),否则, 尺寸为10px X 10px 的元素。
CSS3 uses the border-radius
attribute to set rounded corners in elements. The values, normally, are set in px, and the lowest value allowed is 0px. The visual result are variable, according to the dimensions of the element with this attribute. For example, an element with dimensions 100px X 100px with border-radius: 20px;
, will not get totally rounded(circle), otherwise, an element with dimensions 10px X 10px will be. There are no limit to the maximum value allowed.
问题是:如何根据元素大小计算最大值使其100%四舍五入?
The question is: how to calculate the maximum value, according to the element size, to make it 100% rounded?
编辑:如何计算像素值(px)?
推荐答案
为什么不使用百分比?
border-radius: 50%;
只要确保您使用的是正方形。
Just make sure whatever you're applying it to is square.
这篇关于如何计算边界半径的最大值而不使用百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!