By creating two divs to the right of each other in css?

I wanted to know how to put two divs on each other's right, centered on the page as follows:

 divLeft                     |                     div right
                             |
                             |
                             |
                             |

Thank you:))

+3
source share
3 answers
.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 customize the width value in the wrapper class to suit your needs.

+2
source

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

0
source

Well, depending on how possible it is, you can do the following:

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

I have not tested it, but basically you want to swim it wrong, and then use the margin to push it back to the center line.

0
source

Source: https://habr.com/ru/post/1768801/


All Articles