CSS Property Value How to - Float right and left int the same line








Question

We would like to know how to float right and left int the same line.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.parent {<!--from w  w  w .  j  a  v a 2  s .c om-->
  position: relative;
  border: 1px solid #f00;
  overflow: hidden;
}

.parent .leftbit {
  width: 370px;
  top: 0px;
  float: left;
  background:#AAA;
}

.parent .rightbit {
  width: 220px;
  top: 0px;
  float: right;
  background:#EEE;
}
</style>
</head>
<body>
  <div class="parent">
    <div class="leftbit">abcdef</div>
    <div class="rightbit">111111</div>
  </div>
  <div class="parent">
    <div class="leftbit">ghijk</div>
    <div class="rightbit">222222</div>
  </div>
</body>
</html>

The code above is rendered as follows: