You need to think in terms of% width and% height:
.wrapper{ border:1px solid #F00; width:200px; height:200px; position:relative; } .in{ float:left; width:100px; height:100px; margin:25%; display:inline-block; border:1px solid #00F; } <div class="wrapper"> <div class="in"> DYNAMIC CONTENT </div> </div>
If you use fixed pixel widths, you will need to think about how your% margin will affect internal divs based on space limitations.
For example, you have a container of size 200x200 with an internal DIV of size 100x100. Therefore, if you move the interior by 25% of the appearance, you move 200 * .25 = (50 pixels). 50 + 100 + 50 - 200, which centers your inner div from all sides.
Dan kanze
source share