中间有图像的 WordPress 菜单

WordPress menu with image in middle

我正在尝试创建一个中间有图像的菜单。例如图像左侧的三个链接和图像右侧的三个链接,每个菜单项还必须列出所有子页面。

父级菜单项必须根据在 CMS 中输入的内容动态更新文本,但用户不必能够重新排序或从菜单中添加/删除项目。

执行上述操作的最佳方法是什么?我最初的想法是对所有页面进行硬编码并使用 get_permalink() 来获取 URL 以将它们更改,但这不会考虑上面列出的所有要求。

这里有你想要的答案。有关详细信息,请关注 link

在下面的示例中,徽标位于 ul class 之外,但您也可以在 li class 之间设置徽标。所以徽标在菜单中间。

HTML

<div id="header">
  <a class="logo" href="index.html"><img src="http://i48.tinypic.com/2mob6nb.png" alt="Michigan State" /></a>
  <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="index.html">Stats</a></li>
    <li><a href="index.html">Schedule</a></li>
    <li><a href="index.html">Store</a></li>
    <li><a href="index.html">Gallery</a></li>
    <li><a href="index.html">Roster</a></li>
  </ul>
</div><!--end header-->

CSS

body {  
  font-family: Helvetica, Arial, Century;
  font-size: 12px;
  margin: 0;
  background: url('images/bluebg.jpg') repeat-x top center;
}


#header {
  background-color: #ffd727;
  height: 40px;
  position: relative;
  margin: 150px auto 0;
}


#header ul {
  margin: 0 auto;
  width: 800px;
  padding: 0;
  list-style: none;
}

#header ul li {
  float: left;
  width: 97px;
}

#header ul li:nth-of-type(4) {
  margin-left: 217px;
}

#header ul li a {
  text-transform: uppercase;
  text-decoration: none;
  display: block;
  text-align: center;
  padding: 12px 0 0 0;
  height: 28px;
}

#header ul li a:hover {
  background: rgb(235,200,35);
}

.logo {
  position: absolute;
  left: 50%;
  margin: -48px 0 0 -108px;
}


@media screen and (max-width: 800px) {
  .logo {
    bottom: 100%;
  }

  #header ul li:nth-of-type(4) {
    margin-left: 0;
  }

  #header ul {
    width: 600px;
    position: relative;
  }
}

对于 JS - 请参考下面这个 Link

http://codepen.io/wolfcry911/pen/HyLdg

方法二

你也可以用左右不同的菜单来做..但是方法1最适合wp

http://foundation.zurb.com/forum/posts/1832-logo-centered-in-top-bar