tags:

views:

230

answers:

2

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 divs 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 divs not wrap when the browser is re-sized smaller?

+4  A: 

Wrap them in another div, which has a width (or min-width) specified.

<div class="parentContainer">
    <div class="floater"></div>
    <div class="floater"></div>
    <div class="floater"></div>
</div>

.parentContainer {
    width: 600px;
    overflow: auto;
}

It also helps to have overflow: auto specified on the containing div, to allow its height to match the child floats.

AaronSieb
+2  A: 

Make the container div around them

.container {
width: 500px;
white-space: nowrap;
overflow: visible/hidden/scroll - whichever suits you;
}
easwee