php - 下拉菜单不会横向

标签 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;
    }

}

最佳答案

<li> 使用 css ..如下:但仅适用于 parent li 而不是 child

li{display:inline-block;}

关于php - 下拉菜单不会横向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24552586/

相关文章:

html - 为什么我的导航栏和页脚没有拉伸(stretch)到全宽?

php - Docker-ENTRYPOINT脚本导致重启

javascript - 调整函数大小并更改我的类的 css 值(在 javascript 中)

javascript - jQuery 在滚动时添加和删除类

javascript - Shopify 不执行 jQuery(地理位置脚本)

jQuery 禁用所有重定向(链接、表单提交、window.location 更改等)

Android - 使用带有无序列表 html 标签的 Gmail 发送电子邮件

php - 列类型和 if 语句

php - 使用 PayPal 快速结账时未显示运费

php - 交响乐 2 : manual login and Json Web Token