CSS Layout How to - Three column with fixed size








Question

We would like to know how to three column with fixed size.

Answer


<!--from ww w .j a v  a  2 s.  c om-->
<html>
<head>
<style>
#frame {
  margin-left: auto;
  margin-right: auto;
  text-align: left;
  width: 960px;
}

#page {
  margin: 0px 10px 10px 10px;
}

#header {
  background-color: #cccccc;
  padding: 10px;
  height: 120px;
}

#navigation {
  background-color: #efefef;
  padding: 10px;
  height: 40px;
}

#footer {
  background-color: #cccccc;
  padding: 10px;
  height: 40px;
  clear: both;
  border-top: 20px solid #ffffff;
}

/* 3 columns */
.column1of3, .column2of3, .column3of3 {
  float: left;
  width: 280px;
  background-color: #cccccc;
  padding: 10px;
  margin-top: 20px;
  height: 173px;
}

.column1of3, .column2of3, .columns1and2of3 {
  margin-right: 20px;
}

.columns1and2of3, .columns2and3of3 {
  float: left;
  width: 600px;
  background-color: #cccccc;
  padding: 10px;
  margin-top: 20px;
}
</style>
</head>
<body>
  <div id="frame">
    <div id="page">
      <div id="header">header</div>
      <div id="navigation">navigation</div>
      <div class="column1of3">column 1 of 3</div>
      <div class="column2of3">column 2 of 3</div>
      <div class="column3of3">column 3 of 3</div>

      <div id="footer">footer</div>

    </div>
  </div>
</body>
</html>

The code above is rendered as follows: