CSS Layout How to - column-width: 100px;








Question

We would like to know how to column-width: 100px;.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body {<!--  w  ww  .ja  va 2s  .c  om-->
  column-width: 100px;
  -moz-column-width: 100px;
  -webkit-column-width: 100px;
}

div {
  border: 1px solid #999;
  display: inline-block;
  margin: 10px;
  width: 100px;
}

.block1 {
  height: 100px;
}

.block2 {
  height: 130px;
}

.block3 {
  height: 150px;
}

.block4 {
  height: 100px;
}

.block5 {
  height: 120px;
}

.block6 {
  height: 100px;
}

.block7 {
  height: 120px;
}

.block8 {
  height: 160px;
}
</style>
</head>
<body>
  <div class="block1"></div>
  <div class="block2"></div>
  <div class="block3"></div>
  <div class="block4"></div>
  <div class="block5"></div>
  <div class="block6"></div>
  <div class="block7"></div>
  <div class="block8"></div>
</body>
</html>

The code above is rendered as follows: