Open Source / Free Software developer
These are more or less my notes of an effort to implement a very simple dropdown-like menu that is implemented purely in HMTL and CSS.
It is currently not tested for cross-browser compatibility (it appears not to work in MS IE 5.0) but it should work in most Mozilla-based browsers. If you have any improvements, please send me an email.
This is just a small demo of an idea I had for using CSS in a menu, it is not really production-quality just proof-of-concept.
This solution basically trims the list items to the height of one line if the mouse is not over the list item. This causes the menu to expand one level if the mouse is over an item.
ul.menu li {
display: block;
width: auto;
height: 1em;
overflow: hidden;
}
ul.menu li:hover {
height: auto;
overflow: visible;
}
<ul class="menu">
<li>
Item1
<ul>
<li>Item1.1</li>
<li>
Item1.2
<ul>
<li>Item1.2.1</li>
<li>Item1.2.2</li>
<li>Item1.2.3</li>
</ul>
</li>
<li>
Item1.3
<ul>
<li>Item1.3.1</li>
<li>Item1.3.2</li>
</ul>
</li>
</ul>
</li>
<li>Item2</li>
</ul>
This tries to make an effort of only showing the menu if an option is clicked. This solution only shows the lists if they have a pointer over them or have their parent activated. The HTML code is the same as in the previous example.
ul.menu ul {
display: none;
position: relative;
bottom: 1em;
padding-top: 1em;
}
ul.menu li:active ul {
display: block;
}
ul.menu ul:hover {
display: block;
}