Child div not inlining inside parent div

622 Views Asked by At

I must be doing something stupid or looking over something obvious, because no matter what I do I cannot get these three divs inline inside this parent.

.stats {
  display: inline-block;
  margin-right: 6px;
  float: right;
  padding: 0;
  font-family: "Roboto" sans-serif;
  color: black;
}
.separator {
  background: rgba(47, 187, 255, 0);
  height: 20px;
  width: 1px;
  vertical-align: middle;
  border-left: solid;
  border-width: 1px;
  border-color: rgba(0, 124, 184, 0.7);
  float: left;
  margin-top: 5px;
  margin-left: 4px;
  margin-right: 4px;
  display: block;
}
<div class="stats">
  <div class="points"><b>Lorem </b>&nbsp; 142</pdiv>
  <div class="separator"></div>
  <div class="luck"><b>Ipsum</b>&nbsp; 64% <i>Blabla 3</div>
</div>

What am I doing wrong?

2

There are 2 best solutions below

1
On BEST ANSWER

Added float:left; to the .stats div-children.

.stats {
  display: inline-block;
  margin-right: 6px;
  float: right;
  padding: 0;
  font-family: "Roboto" sans-serif;
  color: black;
}
.stats div{
  float:left;
}
.separator {
  background: rgba(47, 187, 255, 0);
  height: 20px;
  width: 1px;
  vertical-align: middle;
  border-left: solid;
  border-width: 1px;
  border-color: rgba(0, 124, 184, 0.7);
  float: left;
  margin-top: 5px;
  margin-left: 4px;
  margin-right: 4px;
  display: block;
}
<div class="stats">
  <div class="points"><b>Lorem </b>&nbsp; 142</div>
  <div class="separator"></div>
  <div class="luck"><b>Ipsum</b>&nbsp; 64% <i>Blabla 3</div>
</div>

3
On

You need to set display: inline (or inline-block) to the children, not the parent :

.stats {
  display: inline-block;
  margin-right: 6px;
  float: right;
  padding: 0;
  font-family: "Roboto" sans-serif;
  color: black;
}
.stats div {
  display: inline;
}
.separator {
  background: rgba(47, 187, 255, 0);
  height: 20px;
  width: 1px;
  vertical-align: middle;
  border-left: solid;
  border-width: 1px;
  border-color: rgba(0, 124, 184, 0.7);
  margin-top: 5px;
  margin-left: 4px;
  margin-right: 4px;
}
<div class="stats">
  <div class="points"><b>Lorem </b>&nbsp; 142</pdiv>
    <div class="separator"></div>
    <div class="luck"><b>Ipsum</b>&nbsp; 64% <i>Blabla 3</div>
</div>

Edit: I also removed the float: left on separator.