Div with unspecified width (absolute positioning)?

Block-level elements expand vertically to hold their content, but expand horizontally to fill their container. Since you're using absolute positioning though, the semantics of "filling the container" change a bit.

Block-level elements expand vertically to hold their content, but expand horizontally to fill their container. Since you're using absolute positioning though, the semantics of "filling the container" change a bit. Normally browsers will attempt to fill the remaining horizontal space of the browser if the width hasn't been specified (or when width is 'auto', the default width), so what you're describing sounds peculiar.It seems most likely that something else is interfering with the element to cause that behavior (e.g. , a relatively or absolutely positioned element somewhere in the parent chain).

I would try to debug this by seeing if you can replicate the behavior with a root-level div (if you're not already), to eliminate the chance of parent elements causing issues.

Jmar, thanks for your explanation. I do have a relatively positioned div in the parent chain. Reason, I want this absolute div to be positioned on the page at an offset to that content.

Perhaps I'm not doing positioning correctly? I've got stuff that I want to be displayed using normal and floating positioning, and then in the same group of stuff (read div), I have something I want to appear as an offset to that (without using margins, etc) – Ray Sep 7 at 16:34 It's hard to provide more specific advice w/out seeing the full parent chain, but to take a stab, does it appear that the text is wrapping due to the width of the relatively positioned parent div? If so, you can do some hacky stuff with negative margins to exceed that div's boundaries, but you may be better off reconsidering the overall DOM structure you're using.

– jmar777 Sep 7 at 16:41 If I get rid of the relative positioning of the parent element, then I don't get the wrap of the words. However, this element then becomes offset from the browser 0-0 point, which is not what I want. I.e.

I've got a header on the page with menu below it that's repeated on every page. I want to do absolute positioning "relative" to that stuff, so that the element positions correctly, even if the "header material" is changed. – Ray Sep 7 at 16:46 Due to that structure, you're going to need to use an explicit width then.

If you don't use an explicit width (e.g. , 300px), then the width will be determined by the container. Since the container seems to be necessary as an offset container, there will be no way to set the width of the absolutely positioned div based on the width of the browser. You could of course dynamically resize it with the help of some JavaScript, but that's kind of nasty if it can be avoided.

– jmar777 Sep 7 at 16:57 Cool, thanks for the great explanation jmar. – Ray Sep 7 at 17:19.

Try using the css attribute of "width:auto" on the div :).

Width:auto has no effect, but I can add width:100% to do it. But I'm trying to understanding how div widths work. – Ray Sep 7 at 16:40.

It actually works fine for me. But try adding "display:inline;" to the DIV.

Cycero, thanks for your response. I added "display:inline" and it had no effect. Please see comment I added to @jmar777 – Ray Sep 7 at 16:36.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions