开发者

creating two div right next to each other on css? [duplicate]

This question already has answers here: Two divs side by side - Fluid display [duplicate] (9 answers) 开发者_运维问答 Closed 1 year ago.

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

 divLeft                     |                     div right
                             |
                             |
                             |
                             |

thank you :))


.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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜