Forum Moderators: not2easy

Message Too Old, No Replies

Firefox nested/floated div problem

Believe me, I've tried everything to fix this.

         

Kolyana19

10:04 pm on Jul 6, 2005 (gmt 0)

10+ Year Member



Okay, all I want is a very simple arrangement of nested DIVs with some particular behavior, and it seems that this behavior is ultimately stopping all known 'fixes' for the "floated div" issue we're all very aware off.

Using this:
<div id=outerContainer style="text-align: center;">
<div id=subContainer style="display: inline; background: #ccc; position: relative;">
<img ... />
<div>some text</div>
</div>
</div>

The inner div is repeated multiple times, but only one has been included for clairty.

The catch is this: I want the small divs in the main outer container to be CENTRALLY ALIGNED and displayed inline, so they line up next to eachother and cascade down to a new row if the browser is too narrow.

I use the outerContainer to force this text-align: center

The catch is that each subContainer collapses to minimum height and ignores it's content (IN FIREFOX) ... it can be a single image, text ... anything. It then starts exhibiting very odd behavior by essentially spilling it contents all over the place:

I've tried adding the usual clear:both, autoflow:auto, <br/>, heights, widths, and lord knows what else I've found over the course of the last 3 hours ... but enough is enough.

The only thing that works is to add float:left to each sub-container, but then they are not centrally aligned in the main container.

How can I have centrally aligned containing divs, displayed inline, that envelope their content?

Oh, and it's probably relevant, but I'm using this declaration:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

[edited by: tedster at 10:22 pm (utc) on July 6, 2005]

alias

3:12 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



The first and the main thing - it won't be possible to center the containers using text-align:center;

I suppose the simpliest thing for you to do now is to assign a fixed width for the container and make margin: 0px auto; <- this will center it (it only works when the width is specified).

Though I don't know of a way to center each floater regarding each other.

nigassma

10:26 pm on Jul 7, 2005 (gmt 0)

10+ Year Member



try this

<div id=outerContainer style="width: 800px;margin: 35px auto 0;position: relative; text-align: center;">
<div id=subContainer style="display: inline; background: #ccc; position: relative; float: left;">
<img ... />
<div>some text</div>
</div>

I floated the images, added a width to the container and set the margins... this floats the main container in the center of the page... from there you can float the rest of the inner divs and everything is happy.