Since you are using absolute position this happen, is taken off the DOM and search for a new containing block:
The containing block for a positioned box is established by the nearest positioned ancestor
If you don't set the parent with any position
value then the div
is off and takes values in relation to another parent.
Set the position to the outer div.
<div id="outer" style="position:relative">
<div id="inner" style="display:block;position:relative;top:30px;">Text2</div>
</div>
In advice try to handle your styles in CSS file