Hey all,
How do you get a div's width to be 100% of it's container, without hard coding the containers width?
Basically, it seems silly that 100% width is based off of screen width.
After you get 4 or 5 levels deep in divs, you don't want a percent of the screen width, you want a percent of the parent container.
So if you use divs you have to define widths for every parent container?
Grae
BTW: I know you can use offsetWidth of the parent in JavaScript, but setting all the widths in JavaScript gets a little tricky because you have to reset various contains.
Hmm..
A normal block-level, non-floated, static/relative positioned element will take up the full space of it's immediate container.
Otherwise if you're referring to an ancestor container then yes, you'll need to explicitly define the width or calculate it with JS. You may be able to absolutely position it, provided that "container" you *want* is positioned relatively and then use 100% width, provided there are no non-static positioned elements in between those which would mess up the calculations.
Of course, you should really post your *real* code otherwise advice like this might be confusing because we don't understand the context/situation and can't provide specific advice.
Failed to mention...
Meder,
I guess what I failed to mention is that the div is bigger than the container. I would like to do overflow scroll, but the div just resizes it's container. I guess my problem is the div larger than it's original container would have been. Therefore, the my overflow scroll, is useless.
Grae