2

There is an issue with the first three divs which contains other elements in it. If I remove them, then it is working fine but not otherwise. See Output Here

.results{
  text-align: center;
}
.result-box{
  width: 200px;
  height: 250px;
  background-color: red;
  margin: 10px;
  padding: 5px;
  display: inline-block;
}
<div class="wrapper">
  <div class="results">
    <div class="result-box"><p>Hello</p><p>World</p></div>
    <div class="result-box"><p>Nothing</p></div>
    <div class="result-box"><p>Everything</p></div>
    <div class="result-box"></div>
    <div class="result-box"></div>
    <div class="result-box"></div>
  </div>
</div>
Abin Thaha
  • 4,493
  • 3
  • 13
  • 41

2 Answers2

2

best solution for collect divs inside a container is using flex (display:flex) or gird (display:gird) witch grid is not working correctly in old browser ( internet explorer)

but if you don't like to use these methods here is a tricky way

.results{
  text-align: center;
  position:relative;
}
.result-box{
  width: 200px;
  height: 250px;
  background-color: red;
  margin: 10px;
  padding: 5px;
  display: inline-block;
  float:left;
}
<div class="wrapper">
  <div class="results">
    <div class="result-box"><p>Hello</p><p>World</p></div>
    <div class="result-box"><p>Nothing</p></div>
    <div class="result-box"><p>Everything</p></div>
    <div class="result-box"></div>
    <div class="result-box"></div>
    <div class="result-box"></div>
  </div>
</div>
Cyrus Raoufi
  • 526
  • 1
  • 3
  • 27
1

Check the below snippet

.results{
  text-align: center;
  display: flex;
  justify-content: center;
}
.result-box{
  width: 50px;
  height: 150px;
  background-color: red;
  margin: 10px;
  padding: 5px;
  display: inline-block;
}
<div class="wrapper">
  <div class="results">
    <div class="result-box"><p>Hello</p><p>World</p></div>
    <div class="result-box"><p>Nothing</p></div>
    <div class="result-box"><p>Everything</p></div>
    <div class="result-box"></div>
    <div class="result-box"></div>
    <div class="result-box"></div>
  </div>
</div>
Abin Thaha
  • 4,493
  • 3
  • 13
  • 41