Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Float left divs going to next line

Tags:

html

css

I have something similar to below:

<div style="float:left;margin-left:5px;">Test</div>

The issue is that I need to have this div repeat multiple times. If it repeats to many times, instead of forcing you to scroll right to see the rest of it (like I want it to), it instead goes down to the next line.

Example of the issue: http://jsfiddle.net/ruh7z/1/

Any help with this would be great, thanks

like image 707
Ben Avatar asked Dec 29 '11 02:12

Ben


1 Answers

That behavior is exactly what floating is supposed to do. If you use table-cell for your display style, that may give you more of what you're expecting. Note that you'll have to use padding instead of margins if you use table-cell.

.container div
{
    display: table-cell;
    padding-left: 5px;
}

Here's a sample of this in use.

like image 52
Jacob Avatar answered Sep 24 '22 08:09

Jacob