CSS Layout How to - Layout page absolute position








Question

We would like to know how to layout page absolute position.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#wrapper {<!-- w w w  .j  a  v a2s .co m-->
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  border: 1px solid #333;
}

#upperPanel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 100px;
}

#chat {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 200px;
  background: #666;
  overflow: auto;
}

#friends {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 200px;
  right: 0;
  background: #999;
  overflow: auto;
}

#bottomPanel {
  height: 100px;
  background: #EEE;
  position: absolute;
  bottom: 0px;
  left: 0px;
  right: 0px;
}

#bottomPanel textarea {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 10px;
  right: 120px;
  width:85%;
  resize: none;
}

#bottomPanel input[type=submit] {
  position: absolute;
  top: 10px;
  bottom: 10px;
  right: 10px;
  width: 100px;
  width:10%;
}
</style>
</head>
<body>
  <div id="wrapper">
    <div id="upperPanel">
      <div id="chat">

      </div>
      <div id="friends">
      </div>
    </div>
    <div id="bottomPanel">
      <textarea></textarea>
      <input type="submit" value="send" />
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: