I'm working on a game website and want to place two divs inside a 'header' div such that they are horizontally aligned and to the left and right of this container div. See below for an example:
Oli Matt
Here is my attempt. What is my error?
HTML:
<div class="header">
<div class="playerOne">
Oli
</div>
<div class="playerTwo">
Matt
</div>
</div>
CSS:
.header{
display: inline-block;
}
.playerOne{
margin-left: 0;
}
.playerTwo{
margin-right: 0;
}
display:inline-block
will not create a float
issue so there is no need to add clearfixoverflow:hidden
instead of display:inline-block
.header {
display: inline-block;
width: 100%;
border: 1px solid red;
}
.playerOne {
float: right;
}
.playerTwo {
float: left;
}
<div class="header">
<div class="playerOne">
Oli
</div>
<div class="playerTwo">
Matt
</div>
</div>