CSS Layout How to - float absolute








Question

We would like to know how to float absolute.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#container {<!--from   w  w  w .java2s.c  o m-->
  position: relative;
}

#left {
  float: left;
  width: 200px;
  height: 400px;
  background: #cfc;
}

#main {
  position: absolute;
  left: 210px;
  right: 0px;
  background: #f9c;
  height: 400px;
}

h1 {
  clear: both;
}
</style>
</head>
<body>
  <div id="container">
    <div id="left"></div>
    <div id="main">
      <h1>test</h1>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: