HTML Element Style How to - Fill space 3 div








Question

We would like to know how to fill space 3 div.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.container {<!--from   www  .  j av  a2s. c o m-->
  width: 100%;
  min-width: 540px; /* you may want this... */
  margin: 0 auto;
  outline: 1px dashed blue;
  display: table;
}

.bar-light {
  width: auto;
  height: 52px;
  background-color: blue;
  display: table-cell;
}

.bar-dark {
  width: 540px;
  height: 52px;
  background-color: red;
  display: table-cell;
}
</style>
</head>
<body>
  <div class="container">
    <div class="bar-light"></div>
    <!-- should always be containing the whole space left of the bar-dark -->
    <div class="bar-dark"></div>
    <!-- should always be 1040px -->
    <div class="bar-light"></div>
    <!-- should always be containing the whole space right of the bar-dark -->
  </div>
</body>
</html>

The code above is rendered as follows: