CSS Layout How to - Make a 3 column layout fill 100% width








Question

We would like to know how to make a 3 column layout fill 100% width.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#div1 {<!--from   ww w  . j a v a2s. c o m-->
  width: 29.6%;
  border: solid 1px #000;
  float: left;
}

#div2 {
  border: solid 1px #000;
  float: left;
  width: 39.6%
}

#div3 {
  width: 29.6%;
  border: solid 1px #000;
  float: right;
}

#Button1 {
  width: 100%
}

#Button2 {
  width: 100%
}

#Button3 {
  width: 100%
}
</style>
</head>
<body>
  <div id="div1">
    <button id="Button1">Button 1</button>
  </div>
  <div id="div2">
    <button id="Button2">Button 2</button>
  </div>
  <div id="div3">
    <button id="Button3">Button 3</button>
  </div>
</body>
</html>

The code above is rendered as follows: