Pretty simple html codes:
<div style="position: relative; width: 300px; height: 400px; background-color: red">
<div style="position: absolute; top:2px;bottom:2px;left:2px;right:2px; background-color: gray">
content
</div>
</div>
While I want the inner div will hold all the place inside the outer div with (2px margin).
It works in ff/chrome/ie8 Howver it does not work in ie 6 and 7.
What is the problem?
A suggestion:
If you just need the margin, you can use this code, just with the inner
DIValone:If not just for the border, please see the solution to the IE Fix below.
Pretty simple answer:
You need to set the
widthandheight!Screenshot:
Fiddle: http://jsbin.com/okibat/1