views:

41

answers:

3

i wanted to know how to put two div right next each other centered in the page like this:

 divLeft                     |                     div right
                             |
                             |
                             |
                             |

thank you :))

A: 

Using float:left; and display:inline;, also you might want to set the width, using width:200px;.

Christian Sciberras
A: 

Well, depending on how expandable it is you could do the following:

.rightDiv
{
    float: left;
    margin-left: 400px; /* Or whatever */
    width: 400px;
}
.leftDiv
{
    float: right;
    margin-right: 400px;
    width: 400px;
}

I haven't tested it but basically you want to float them the wrong way and then use the margin to push it back towards the center line.

Josh K
A: 
.float-left
{
  float: left;
}

.float-right
{
  float: right;
}

.wrapper
{
  width: 500px;
}

<div id="WrapperDiv" class="wrapper">
    <div id="RightDiv" class="float-right">Content for right div goes here</div>
    <div id="LeftDiv" class="float-left">Content for left div goes here</div>
</div>

You can adjust the width value in wrapper class to suit your needs.

Mahesh Velaga