Page Widget How to - Force inline-block elements to wrap text








Question

We would like to know how to force inline-block elements to wrap text.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--from   ww w .  ja va 2 s. c  om-->
  background: #EEE;
  display: inline-block;
  height: 100px;
  width: 300px;
}
</style>
</head>
<body>
  <div> asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asd fasdfa sdf asdf </div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</body>
</html>

The code above is rendered as follows: