Precentage Calculation on two objects of different sizes that returns the same result

18 Views Asked by At

I'm try to work out an absolute value in relation to two percentage values.

I have an object (let's call it 'a') that is 75% of the width of it's containing, or parent object. This child object 'a' has a border that is 5% it's own width.

Using purely percentages only, how would I set a border on the parent object (let's call this 'b'), that is the same width as the inner container's border, but only via a mathematical percentage calculation?

In summary, I need a border on both objects, that is the same width on each in absolute terms, but which is calculated via percentages not absolute values. Is this even possible? The child object inside the parent object is 75% of the width of the parent, so I'm thinking it isn't possible.

I'm really, really stuck and want to bang my head against the wall.

Emily

1

There are 1 best solutions below

0
On

I will assume you want the borders to be contained strictly inside the objects, which we shall think of as boxes. You can work out what size your border should be by supposing the parent has a width of 100 (with what ever units you want). The inner box will have width 75. The border of the inner box has width which is 5% of 75, so 75/20, so 3.75. These numbers translate straight to percentages in relation to the parent box, so the border of the inner box has width 3.75% of the width of the larger box.