Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to arrange many <div> elements side by side with no wrap [duplicate]

Tags:

There are three div elements side by side in a container div, with smaller width than children total width. Here you can find the Fiddle of the case:

I want to make container div scroll horizontally in order to show other children.

How can I arrange children not to wrap inside container div? It scroll vertically now, I want it to scroll horizontally.

like image 960
Reza Owliaei Avatar asked Apr 22 '12 15:04

Reza Owliaei


People also ask

How do I put multiple divs side by side?

Three or more different div can be put side-by-side using CSS. Use CSS property to set the height and width of div and use display property to place div in side-by-side format. float:left; This property is used for those elements(div) that will float on left side.

How do I keep my div from wrapping?

If you want to prevent the text from wrapping, you can apply white-space: nowrap; Notice in HTML code example at the top of this article, there are actually two line breaks, one before the line of text and one after, which allow the text to be on its own line (in the code).

How do I align two elements side by side in a div?

The most common way to place two divs side by side is by using inline-block css property. The inline-block property on the parent placed the two divs side by side and as this is inline-block the text-align feature worked here just like an inline element does.

How do I put multiple divs on the same line?

To display multiple div tags in the same line, we can use the float property in CSS styles. The float property takes left, right,none(default value) and inherit as values. The value left indicates the div tag will be made to float on the left and right to float the div tag to the right.


1 Answers

Change float: left to display: inline-block; and add white-space: nowrap to the container.

like image 189
Niet the Dark Absol Avatar answered Oct 07 '22 10:10

Niet the Dark Absol