HTML Element Style How to - Table cell based three column layout








Question

We would like to know how to table cell based three column layout.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--   w w w. ja va 2s .  co  m-->
  display: table;
  table-layout: fixed;
}

div div {
  display: table-cell;
  width: 100px;
}

div div:nth-child(2) {
  width: 400px;
}
div:nth-child(1) {
  background: #a31
}

div:nth-child(2) {
  background: #aa1
}

div:nth-child(3) {
  background: #3a1
}
</style>
</head>
<body>
  <div>
    <div>Kolonne 1</div>
    <div>Kolonne 2</div>
    <div>
      Kolonne 3<br /> this is a test. 
      this is a test. this is a test. this is a test. 
      this is a test. this is a test. this is a test. 
      this is a test. this is a test. this is a test. 
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: