四舍五入百分比值总计超过100 [英] Round off percentage values summed up to more than 100

查看:896
本文介绍了四舍五入百分比值总计超过100的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个典型的问题。我在div里面有三个div。宽度以四舍五入百分比指定。



值是

66.6666 - > 67%

16.6666 - > 17%

16.6666 - > 17%





总计高达101%。



所以最后一个div不适合它。它降下来了。我需要让三个div在同一基线(水平)。



如何解决这个问题?

解决方案

技巧是不使用最后一个数字的百分比...设置如下

 lastwidth = 100  -  67  -  17 



OR

确保始终向下舍入或截断计算出的值

Hi,

I have got a typical problem. I have three divs inside a div. The width is specified in rounded off percentages.

Values are
66.6666 --> 67%
16.6666 --> 17%
16.6666 --> 17%


Total comes up to 101%.

So last div does not fit into it. It comes down. I need to make three divs to be in same base line(horizontally).

How do I solve this issue?

解决方案

The trick is not to use percentage for the last figure ... set it as follows

lastwidth = 100 - 67 - 17


OR
Make sure you always round down, or truncate, the calculated valuse


这篇关于四舍五入百分比值总计超过100的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆