Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: make dropdown submenu appear below parent <ul> <li>

Tags:

html

css

I am trying to build a CSS dropdown menu. The problem is that all child nodes in the ul li tree appear on the same row, instead of below the parent. How do I make the subcategories appear BELOW the parent ?

like image 494
DreamWave Avatar asked Nov 29 '25 08:11

DreamWave


2 Answers

Add display:block; float: left;position: relative; on the li to establish a containing block and then position:absolute; top:100%; left:0; on the sub-menu ul to position it with respect to its containing block.

like image 87
Alin Purcaru Avatar answered Nov 30 '25 23:11

Alin Purcaru


You can use css to position the submenu.

ul li {
    position: relative;
}

ul li ul.sub {
    position: absolute;
    left: 0;
    top: 100%;
}
like image 27
skajfes Avatar answered Nov 30 '25 21:11

skajfes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!