views:

70

answers:

5

I have a simple HTML layout:

<div style="position:relative; width:200px">
   <div style="position:absolute; top:0; left:0; background-color:red; z-index:-1; width:100%; height: 100%"></div>
   Some text goes here....
</div>

Something like this works fine in all the browsers, except for IE6. As the text is added the top div is stretched and absolutely position div is stretched as well. But in IE6 the absolutely position div will always stay only 1 line in height. I know that IE6 can't dynamically recalculate sizes, and because of that you have to set height: 100% on the body tag if you ever want to use height: 100% anywhere on the page, but in this case, I can't set height:100% on the outer div, since I want it to be just the right size for the text inside of it. Any help?

A: 

Add overflow: hidden; to the absolute div.

prodigitalson
Tried that, it didn't do anything at all..
Ilya Volodin
A: 

http://stackoverflow.com/questions/1970289/giving-height-to-absolutely-positioned-divs-in-ie6

mangokun
Right, it's exactly the same problem, but there's no answer for that in that thread... So doesn't help me much
Ilya Volodin
A: 

an example solution which makes use of javascript(jquery).

http://jsbin.com/ohipu3

mangokun
Sorry, can't use JavaScript for something like this. This is a basic layout problem, JavaScript shouldn't be involved in something like that. More than that, this construction could be repeated on the page hundreds of times, and I'm not going to slow down the page by running all that JS code.
Ilya Volodin
A: 

my 2nd attempt, without using javascript, but illegally moved around the divs.

http://jsbin.com/ohipu3/2

mangokun
Thanks for your answer, but I think you missed the point of the problem. I have to have 2 divs occupy the same space, so that one of them could hold the text and the other one could hold graphics that would act as a background. The one with the graphics have to be positioned absolutely and have to have height 100% since the height of the text is variable. IE6 can't calculate the height of the inner container if you don't have height of the outer container set to a number or percentage. There's got to be some sort of work around for this issue.
Ilya Volodin
A: 

This is a known bug in IE6 but for the life of me I can't recall the solution. I'll look it up but, off the top of my head, try adding 'line-height:1', or some value, and see if it fixes it.

Rob
Thanks, tried line-height, overflow, all of the standard stuff and nothing is working. But line-height and overflow is for fixing the other IE6 issue where even empty divs are always have the height of one line of text...
Ilya Volodin