Converting 390px to Percent?

How do I do this?

390px to Percent?

1 Like

(390px / total px) x 100

Is there a decimal?


Not as long as total px is 1

I don’t get it.

The height inside the box is 390px, I want to covert that to percent.

10px / 100px = .10
.10 x 100 = 10 percent

(390px / total height px) x 100 = percent

390px is equivalent to 61% ?

I think I got it.

As long as “total pixels” is ~639 px, yes

The total width is 640px, does something have to change?

Sorry, you lost me.

You asked about converting units of measurement (height), but now you mention width.
I am not understanding why determining a measure would have anything to do with whether or not something might need to change.

Perhaps it would be best if you post some code to put things into some context?


390 is what percent of 640? Calculate: 60.9375%

It appears to me that what you are trying to do is to set the height in such a way that if the width decreases, the height will decrease to maintain the same aspect ratio. Is that correct?

(This may work for the sceario you have in mind; without further information, it’s impossible to say. However, as has been pointed out to you on numerous previous occasions, fixed dimension containers are generally a bad idea on the web, as the layout can easily break if somebody has their default font set to a different size than yours.)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.