Two divs side by side – Fluid display [duplicate]

Try a system like this instead:

.container {
  width: 80%;
  height: 200px;
  background: aqua;
  margin: auto;
  padding: 10px;
}

.one {
  width: 15%;
  height: 200px;
  background: red;
  float: left;
}

.two {
  margin-left: 15%;
  height: 200px;
  background: black;
}
<section class="container">
  <div class="one"></div>
  <div class="two"></div>
</section>

You only need to float one div if you use margin-left on the other equal to the first div’s width. This will work no matter what the zoom and will not have sub-pixel problems.

Leave a Comment