Home › Forums › CSS › RWD: struggle with flexible padding context › Reply To: RWD: struggle with flexible padding context
He’s basically explaining in this abstracted way the converting of set pixels to percentages on elements.
Ahh. Well, the better solution is to just not do that.
<div id=parent>
<p id=child>Hello!></p>
</div>
If #parent
is 200px wide, and you want #child
to be half the width of #parent
, then it doesn’t matter how wide the parent is: set the child’s width to 50%
.
Similarly, if #parent
is 200px wide, and you want #child
to be 100px wide, it doesn’t matter that 100/200 = .5 = 50%: set the child’s width to 100px
.
Percentages are good for RWD if you design with them. Designing in pixels and then converting them all to percentages has no benefit. It just makes your code more complicated and fragile. If you want pixels, use pixels.
So @Ramone kudos for finding this error, confirmed by the writer himself!
Well, there ya go. Glad you got an answer!