I have this menu using just CSS and HTML. Some of the sub-menus are long, so I would like to sub-divide them into separate lists of up to 5 items and display them side by side instead of underneath each other.
So I've put them in a <div>
and created 2 separate <ul>
items. I tried to make them display: inline
and set the maximum height of the <div>
to 100px
but it doesn't really force the browser to put the second <ul>
beside the first one.
<li>
<a href="#">Sub Item 1.2 Can be long</a>
<div>
<ul>
<li><a href="#">Sub Item 1.2.1</a></li>
<li><a href="#">Sub Item 1.2.2</a></li>
<li><a href="#">Sub Item 1.2.3</a></li>
<li><a href="#">Sub Item 1.2.4</a></li>
<li><a href="#">Sub Item 1.2.5</a></li>
</ul>
<ul>
<li><a href="#">Sub Item 1.2.6 From here should be in 2nd col</a></li>
<li><a href="#">Sub Item 1.2.7</a></li>
<li><a href="#">Sub Item 1.2.8</a></li>
<li><a href="#">Sub Item 1.2.9</a></li>
<li><a href="#">Sub Item 1.2.10</a></li>
</ul>
</div>
</li>
Full working sample here: http://jsfiddle.net/nhfHw/17/ To see the issue just hover over Item 1 > Sub Item 1.2 Can be long
Apart from this I would like to make the menu open up the sub-levels on click
rather than hover
but I guess its not possible using just CSS. What is the best approach to do it in javascript?