CSS Layout How to - Align inline divs left and right








Question

We would like to know how to align inline divs left and right.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.container {<!--from   ww w  .j  ava 2s  .c  om-->
  width: 600px;
  border: 1px solid blue;
}

.inlineLeft, .inlineRight {
  display: inline-block;
}

.inlineRight {
  display: inline-block;
  position: absolute;
  right: 0;
}
</style>
</head>
<body>
  <div class="contailner">
    <div class="inlineLeft">Item 1</div>
    <div class="inlineRight">Item 2</div>
  </div>
</body>
</html>

The code above is rendered as follows: