views:

31

answers:

3

I have a set of dynamically generated content - anywhere between 1 and about 25 blocks (each of which I want to be about 250px wide.

Clearly, this can run off-screen, but that's fine since my design allows for horizontal scrolling (using jQuery - I don't want the browser to do it with its own scroll bars).

So what CSS - cross-browser - is the best approach? Floats seem to wrap unreliably, and the dynamic nature of the content which changes frequently through ajax calls - means that recalculating the container width is not very practical.

Other CSS-based option?

A: 

Other than floats? Tables :D Seriously, use floats.

myfreeweb
A: 

Use a div container with the absolute witdh set, allow overlow, and floats for each box. This will allow the boxes overflow off the right of the screen.

Martin
This is how I went. It meant the additional step of calculating the width (since the number of boxes can change), but there didn't seem a better solution.
JOhnC
A: 
#container { 
  overflow-x: auto; 
  white-space: nowrap; 

  width: XXXpx; height: XXXpx;
}
#container .block { 
  float: left; 
}

The overflow-x setting will ensure a scrollbar if the content extends beyond the width, the white-space setting will ensure all content is on one line.

mVChr