javascript - Expandable menu box (horizontally) -
i playing around idea :
in block have 2 <a>
s buttons , <ul>
, tried float
ing them make them stick together. , main idea achieve effect manipulation width/display state of ul
or menu section.
<nav> <a class="nav-btn">logo</a> <ul> <li><a href="">menu 1</a></li> <li><a href="">menu 1</a></li> <li><a href="">menu 1</a></li> <li><a href="">menu 1</a></li> <li><a href="">menu 1</a></li> </ul> <a class="nav-btn">logo</a> </nav>
but main question "how make widths flexible , automatic?" no, percentages or pixels! main section(grey background) should expand/and collapse automatically , take space needed based on content. , when menu toggled off , hypothetically set width of "menu" zero, background should adjust , 2 buttons should picture.
what structure or html suggest?
much appreciated!
you can use html structure is. have set following css properties basic layout set up:
a, li { display: block; float: left; }
than can toggle display property of <ul> via javascript. see: js fiddle
you can use nav's hover state toggle li's visibility via css
ul { display: none; } nav:hover ul { display: block; }
see: css fiddle
if logo's not links might want use div's instead of a's.
Comments
Post a Comment