How to create equal height columns with CSS?

CSSWeb DevelopmentFront End Technology

To create equal height columns with CSS, the code is as follows −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .container {
      display: table;
      width: 100%;
   }
   .column {
      display: table-cell;
      padding: 16px;
      background-color: greenyellow;
   }
   .column:nth-of-type(2n-1) {
      color: red;
      background-color: yellow;
   }
</style>
</head>
<body>
<h1>Equal Height Columns Example</h1>
<div class="container">
<div class="column">
<h2>Column 1</h2>
<h2>Column 1</h2>
<h2>Column 1</h2>
</div>
<div class="column">
<h2>Column 2</h2>
<h2>Column 2</h2>
<h2>Column 2</h2>
</div>
<div class="column">
<h2>Column 3</h2>
<h2>Column 3</h2>
<h2>Column 3</h2>
</div>
</div>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 07-May-2020 12:50:57
Advertisements