javascript - Expandable menu box (horizontally) -


i playing around idea : enter image description here

in block have 2 <a>s buttons , <ul> , tried floating 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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -