HTML Element Style How to - Make UL/OL Horizontal scrolling








Question

We would like to know how to make UL/OL Horizontal scrolling.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
ul {<!--from   w w w.java 2s.co m-->
  overflow-x: auto;
  white-space: nowrap;
}

ul li {
  display: inline;
}
</style>
</head>
<body>
  <ul>
    <li>Test1</li>
    <li>Test2</li>
    <li>Test3</li>
    <li>Test4</li>
    <li>Test5</li>
    <li>Test6</li>
  </ul>
</body>
</html>

The code above is rendered as follows: