2017-06-22 44 views
1

我有導航條,代碼如下...如何移動圖標居中

<?php 
     NavBar::begin(['brandLabel' => '', 
        'options' => [ //'class' => 'navbar-inverse navbar-fixed-top', 
            'style' => 'height: 30px; margin-top:-10px;',] 
           ]); 
     echo Nav::widget([ 
        'items' => [['label' => 'Home', 'url' => ['/site/index']], 
           ['label' => 'About', 'url' => ['/site/about']],], 
        'options' => ['class' => 'navbar-nav','style' => 'align:center',], 
           ]); 
     NavBar::end(); 
     ?> 

是可以移動圖標殿居中?.. 引導導航欄左,導航欄,右邊是工作correclty ..

回答

0

您可以在菜單

<?php 
NavBar::begin(['brandLabel' => '', 
     'options' => [ 
      'class' => 'navbar navbar-fixed-top clients', 
      'id' => 'my-menu', 
     ], 
]); 
echo Nav::widget([ 
    'items' => [['label' => 'Home', 'url' => ['/site/index']], 
     ['label' => 'About', 'url' => ['/site/about']],], 
    'options' => ['class' => 'navbar-nav', 'style' => 'align:center',], 
]); 
NavBar::end(); 
?> 

添加自己的ID,做任何你想要的CSS

div#my-menu-collapse ul li { 
    text-align: center; 
    margin: 0 auto; 
} 
2

這一個應該工作,更好地將內聯CSS移動到某個類。

NavBar::begin(['brandLabel' => '', 
       'options' => [ //'class' => 'navbar-inverse navbar-fixed-top', 
           'style' => 'height: 30px; margin-top:-10px;',] 
          ]); 
    echo Nav::widget([ 
       'items' => [['label' => 'Home', 'url' => ['/site/index']], 
          ['label' => 'About', 'url' => ['/site/about']],], 
       'options' => ['class' => 'navbar-nav','style' => 'display: flex;justify-content: center;float: none;',], 
          ]); 
    NavBar::end();