Converting px to percent

198 of 606 gives me, 32.67326732673268%

How many of the numbers do I use, or do I use the entire thing?

<button id="playButton" style="display:block;width: 606px;height:50px;border-radius:;background-image: linear-gradient( to right,#000000 198px,#0059dd 198px, #0059dd 201px, #000000 201px, #000000 399px, #0059dd 399px, #0059dd 402px, #000000 402px );border: 3px solid #0059dd; cursor: pointer;font-family: Tahoma; font-weight: bold;font-size:23px; color:#000000;"</button>

32.67 should be plenty.

1 Like

thank you.

Is there ever a reason where you would use more than 4 numbers?

And an example would be?

I can’t see a reason to use more than 2 decimal places (ie. numbers after the decimal point)

1 Like

Ok, got it, and thanks.

Unless you are launching your button to the outerspace, 2 decimal places should be just fine.

However, make a habit of taking the floor after two digits.

For example, for 32.567, take 32.56.

This is because, (imaginary case) suppose you want a six column layout and want to equally divide each of the layout. Each of them would equal to 16.666666666. If you take the upper limit after the second decimal point (i.e. 16.67), the total would exceed 100% resulting into 100.02%.

This would break your layout with the 6th layout in the next row.

Fun fact: NASA uses 15 decimals of PI at max.

2 Likes

Why would you use percentages when you have a fixed width? Use px and be exact.

2 Likes

Thanks.

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