How do you make DIV's that are floated left next to each other not wrap when the browser is re-sized such that the viewport becomes smaller?
div {
float: left;
}
For example when the browser is fully maximized the div
s line up like this:
|div| |div| |div| |div| |div| |div| |div| |div|
But when the browser re-sized smaller this happens:
|div| |div| |div| |div| |div|
|div| |div| |div|
How can I make the div
s not wrap when the browser is re-sized smaller?
It is actually really simple. Example of code:
Make the container div around them
Wrap them in another div, which has a width (or min-width) specified.
It also helps to have overflow: auto specified on the containing div, to allow its height to match the child floats.
I realize that it's fashionable to hate on tables, but they can be useful.
http://jsfiddle.net/td6Uw/
Instead of floating the divs, place them in a table and wrap the table with a size-constrained div. The TR will prevent wrapping.
Also, I used DIVs inside the TDs to make cell styling easier. You could style the TDs if you spend the time, but I find them hard to style and usually wimp out and just use the DIV-in-TD method employed by my fiddle.
I'm pretty late to the game, but here's what I've found that works:
Let's say you have a navigation structured as:
To get it to display the links inline, without ever wrapping, you can simply use:
No fixed widths or anything required.
Fiddle: http://jsfiddle.net/gdf3prb4/