HTML Element Style How to - Create Horizontal list which is scrolling








Question

We would like to know how to create Horizontal list which is scrolling.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
ul {<!--from  ww  w  .  j a v a 2s.com-->
  width: 5em;
  white-space: nowrap;
  overflow-x: scroll;
  line-height: 2em;
}

ul li {
  display: inline-block;
}
</style>
</head>
<body>
  <ul>
    <li><a href="#">item 1</a></li>
    <li><a href="#">item 2</a></li>
    <li><a href="#">item 3</a></li>
    <li><a href="#">item 4</a></li>
  </ul>
</body>
</html>

The code above is rendered as follows: