V
V
VitalyGovarkov2015-05-20 14:26:11
css
VitalyGovarkov, 2015-05-20 14:26:11

How to calculate margins as a percentage?

Good day!
I have a 960px wide layout with 10px side padding to convert these margins to percentages I divide by 10px/940px*100 but the margins are 14px and the blocks don't match the layout. Everywhere it is written that it is necessary to calculate exactly this way. Who can tell what is the problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
reifter, 2015-05-20
@VitalyGovarkov

960px = 100%
1px =100/960= 0.10416%
And now we calculate:
940px = 0.10416%*940px=97.916%
10px = 0.10416%*10px = 1.0416%
jsfiddle.net/jnrt7v12

I
Ivan, 2015-05-20
@LiguidCool

Do you want to know the padding width in %?
960 -> 100%
10 -> x
x*960 = 10*100
x= 10/960*100
Two for you :-P

M
Mikhail Lyalin, 2015-05-20
@mr_jok

give up fixed sizes and px

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question