CSS Layout How to - Fill space left from centered div with fluid layout and max-width








Question

We would like to know how to fill space left from centered div with fluid layout and max-width.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
html, body {<!--  w ww  . ja v a  2 s  .  c  om-->
  height: 100%;
  width: 100%;
}

#content {
  height: 100%;
  margin-left: auto;
  margin-right: auto;
  max-width: 760px;
  min-width: 80%;
  border: solid red thin;
  box-sizing: border-box;
  float: left;
  background:#EEE;
}

#left, #right {
  float: left;
  border: solid blue thin;
  box-sizing: border-box;
  width: 9.5%;
  height: 100%;
  background:#AAA;
}
</style>
</head>
<body>
  <div id="left"></div>
  <div id="content"></div>
  <div id="right"></div>
</body>
</html>

The code above is rendered as follows: