Css accordion menu, how to set height to automatic?


Tags: html,css,menu,accordion

Problem :

I've got this accordion menu: Codepen link

The problem is that the height of the expanding divs is "hardcoded" (see where the css comment is), whereas I need it to expand according to the number of submenu items.

Any ideas how to fix this?



Solution :

Use height: auto

#accordion div:hover {
    height:auto; /* THIS NEEDS TO ADJUST AUTOMATICALLY */
}

    CSS Howto..

    How to vertically center links in a menu?

    Slideshow flickering image on :hover

    How to programmatically change the css background image?

    How to remove space between two buttons in a table row or “column”?

    how to set menu to activate always hover effect on [closed]

    Formatting text, Suggestions with how-to?

    CSS table: How to position action buttons left to each row

    How to get a working CSS zigzag border?

    How do I increase the height of a menu divider in a navigation?

    How to show hidden div in the same line as the paragraph text?

    How to remove css : hover using jquery?

    3 column layout, same height, middle column full size. How to do it without “table-cell”

    how to set css position absolute in hover state

    How to make a jQuery script and CSS responsive?

    CSS position: absolute - understanding how to center text inside a div box

    How to remove all pseudo selectors from a CSS selector string using Javascript?

    How can we wrap the line based on border size of windows browser?

    How to vertically align data in the center of a table cell in HTML?

    How can i reposition a sub ul in a responsive web site

    How do I line up CSS elements? Is there a tool I can use?

    How to get divs and anchors stacked on top of each other with the same width

    How to avoid background image tile when browser window resizes

    How to lay down elements vertically from top to bottom, and then from right to left, using a clean HTML markup?

    How to make changes in wordpress template. Css direct edit not working

    how to use css align control one row

    How do you apply a fading overlay to an image in CSS?

    How to get an interactive geographic map for a country? [closed]

    How to animate semicircle-like meter indicating elapsed time with HTML/CSS/JS?

    How can I build a dynamic menu using CSS and JavaScript?

    How do I get these hover effects but with diamonds instead of circles