CSS Layout How to - Force a fluid DIV to expand to full available width








Question

We would like to know how to force a fluid DIV to expand to full available width.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--from  www.  j ava2  s .c o  m-->
  float: left;
  height: 50px;
  width: 200px;
}

#left-sidebar, #right-sidebar {
  background: lime;
}

#main-content {
  background: yellow;
  min-width: 200px;
  width: calc(100% - 400px)
}
</style>
</head>
<body>
  <div id="left-sidebar">Left</div>
  <div id="main-content">Main</div>
  <div id="right-sidebar">Right</div>
</body>
</html>

The code above is rendered as follows: