HTML Form How to - Scale button to div height Table cell








Question

We would like to know how to scale button to div height Table cell.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#menubar {<!--from  w w  w.ja  v  a2 s  .c  om-->
  width: 100%;
  height: 100%;
  display: table;
  table-layout: fixed;
}

#menu {
  display: table-row;
}

#menu .button {
  display: table-cell;
  border: 1px dotted blue;
  height: 100%; /* scale the height with respect to the table */
}

#menu .button Button {
  width: 100%;
  height: 100%; /* scale the height with respect to the table cell */
}
</style>
</head>
<body>
  <div id="menubar">
    <div id="menu">
      <div class="button">
        <Button>Button 1</Button>
      </div>
      <div class="button">
        <Button>Button 2</Button>
      </div>
      <div class="button">
        <Button>Button 3</Button>
      </div>
      <div class="button">
        <Button>Button 4</Button>
      </div>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: