下拉菜单不会横向

时间:2014-07-03 11:31:34

标签: php jquery html css drop-down-menu

我需要有关下拉菜单的帮助

我想将下拉菜单设为横向(见下图)

http://i.stack.imgur.com/etEeB.jpg

但我的下拉菜单已经触底。

enter image description here

这里是代码:(来自yootheme_balance的模板)

/*
Function: process

  Returns:
    Object
    */  
    public function process($module, $element) {

  foreach ($element->find('ul.level2') as $ul) {

    // get parent li
    $li = $ul->parent();

    // get columns
    $columns = (int) $li->attr('data-menu-columns');

    if ($columns > 1) {

    $children = $ul->children('li');
    $colrows  = ceil($children->length / $columns);
    $column   = 0;
    $i        = 0;

    foreach ($children as $child) {
        $col = intval($i / $colrows);

        if ($column != $col) {
      $column = $col;
        }

        if ($li->children('ul')->length == $column) {
      $li->append('<ul class="level2"></ul>');
        }

        if ($column > 0) {
      $li->children('ul')->item($column)->append($child);
        }

        $i++;
    }

    } else {
    $columns = 1;
    }

    // get width
    $width = (int) $li->attr('data-menu-columnwidth');
    $style = $width > 0 ? sprintf(' style="width:%spx;"', $columns * $width) : null;

    // append dropdown divs  
    $li->append(sprintf('<div class="dropdown columns%d"%s><div class="dropdown-bg"><div></div></div></div>', $columns, $style));
    $div = $li->first('div.dropdown div.dropdown-bg div:first');

    foreach ($li->children('ul') as $i => $u) {
    $div->append(sprintf('<div class="width%d column"></div>', floor(100 / $columns)))->children('div')->item($i)->append($u);
    }
  }

  return $element;
    }

}

1 个答案:

答案 0 :(得分:0)

<li>使用css,如下所示:但仅适用于父李而不是孩子

li{display:inline-block;}