1

我在以下 wordpress 网站上有一个导航栏:http: //tarjom.ir/demo/pwp

这个导航栏有两个主要问题:

1-我不能在中间垂直对齐它。

2-有一个div包装器作为<ul>标签的父级,我无法删除它。但是我已经设置了'container' => '',但它不起作用。

<!-- Navigation bar-->
  <div id='wp_nav_section' class='grid-100 black-gray-bg font-roya' style='min-height: 100px; display: block;height:100%;'>
    <?php wp_nav_menu(array("container" => 'nav')); ?> 
  </div>
<!-- End of navigation bar. -->

这是我的wordpress导航代码:

这是我所有与 wordpress 导航相关的 CSS:

.menu
    {
        height: 65px;
        min-height: 60px;   
        padding: 0px;
        text-align: right;
        background-color: #111;
        margin-bottom: 10px;
    }
.menu ul
    {
     direction: rtl;
     width: 70%;
     margin-right: auto;
     margin-left: auto;
     overflow: hidden;
     height: auto;
     padding-top: 0px;
    }
.menu li
    { 
      padding: 0px 0px;
      display: inline-block; 
    }
    .menu li a
    {
      color: white;
      text-decoration: none;
      display: block ;
      height: 45px;
      background-color: black; 
      border-right: 2px #333 solid; 
      padding: 16px 7% 3px 3%;
      box-sizing: border-box;
      width: 100px;
      margin: 0px 0px;
      font-size: 110%;
    }
    .menu li a:hover
    {
        background-color: #333;
        border-right: 2px #F90 solid;
    }

我需要<ul>标签在<div>包装器中垂直居中。

先谢谢了。

4

2 回答 2

2

.menu{}从类中删除高度。这将解决您的垂直对齐问题。

于 2013-08-17T04:53:26.187 回答
1

I would try this, if you haven't already:

<?php wp_nav_menu( 
array ( 
'container' =>false,
'items_wrap' => '%3$s', //"%3$s" is the li list itself. See below for the default value.
 ) ); ?>

The default values for these two parameters are:

'container'       => 'div',
'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',

So I would make sure to define those the way you want them in your call to wp_nav_menu().

You can read more info on my post at http://icode4you.net/wordpress-tricks-customizing-the-output-of-wp_nav_menu/

To center the UL within a div, I would use this code:

<style>
div {
text-align:center;
}

ul {
display:inline-block;
}

</style>

Let me know if you would like any more information or help :)

于 2014-05-25T21:48:53.280 回答