menu

arrow_back How to create a menu?

by
1 vote
There is a menu like this:
fdcb8ce389644c7686ba63eaf364ada2.png

This submenu appears when you hover over the catalog item. Everything seems simple, 3 columns. And how to create such that, for example, when you pull on WordPress or other CMS, all this work? So you could just set a fixed width, position absolute, and 3 columns with float left or inline-block... And how to be when you don't know in advance the number of columns, their height...

2 Answers

by
1 vote
Most likely, the menu will be formed from an array. If you know the sequence number of the element, and if it is divisible by a certain number without a remainder, you close the column and create a new one.
Roughly it looks like this.
<? $i=1 ?>
<ul>
<? foreach ($arMenu as $menu){ ?>
<li><?=$menu['name']?></li>
<?
if ($i%5==0){
?></ul><ul><?
}
?>
<? }?>
</ul>
every 5 points ul will be closed and a new one will be opened.
by
1 vote