Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I line up 3 divs on the same row?

Tags:

html

css

Can someone please help me with this problem as i have been dealing with it for a long time now....

I am trying to get 3 divs on the same line next to each other one of the divs looks like this:

<div>     <h2 align="center">San Andreas: Multiplayer</h2>     <div align="center">     <font size="+1">         <em class="heading_description">15 pence per slot</em>       </font>       <img src="http://fhers.com/images/game_servers/sa-mp.jpg" class="alignleft noTopMargin" style="width: 188px; ">       <a href="gfh" class="order-small">         <span>order</span></a>     </div> 

and the other two are the same divs please help me get all three divs on the same line one on the right one on the mid and one on the left

like image 883
Mr.Blue Avatar asked Dec 31 '11 22:12

Mr.Blue


People also ask

How do I place 3 divs in a row?

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 put multiple divs in one 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.

How do you put 3 boxes side by side in HTML?

Three or more different div can be put side-by-side using CSS in the same div. This can be achieved with flexbox – but note that you will need to use wrapper divs and apply different flex-directions to each in order to make the grid layout work. Use CSS property to set the height and width of div.


1 Answers

I'm surprised that nobody gave CSS table layout as a solution:

.Row {      display: table;      width: 100%; /*Optional*/      table-layout: fixed; /*Optional*/      border-spacing: 10px; /*Optional*/  }  .Column {      display: table-cell;      background-color: red; /*Optional*/  }
<div class="Row">      <div class="Column">C1</div>      <div class="Column">C2</div>      <div class="Column">C3</div>  </div>

Works in IE8+

Check out a JSFiddle Demo

like image 134
avrahamcool Avatar answered Sep 26 '22 05:09

avrahamcool