I have implemented the default nav-bar from Bootstrap 3 in my WordPress theme, with some modifications renaming it '.navbar-custom'.
On mobile-sized screens, the default 'toggle' appears in the right corner, while the '.navbar-brand' is on the left.
My goal is to center the 'toggle' in mobile mode and also center the '.navbar-brand' (it would be ideal if the toggle could go underneath the site logo).
I have tried various examples in jsfiddle, but none seem to work for me. The only one that showed any visual change was the following CSS snippet within a media query:
.navbar-toggle {
width: 100%;
float: none;
margin: 0 auto;
}
However, this code simply moved the toggle to the left of the nav-bar. Here is my typical navbar code:
<header>
<nav class="navbar navbar-custom row" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-brand">
<?php if (get_theme_mod(FT_scope::tool()->optionsName . '_logo', '') != '') { ?>
<a class="mylogo" rel="home" href="<?php bloginfo('siteurl');?>/" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"><img relWidth="<?php echo intval(get_theme_mod(FT_scope::tool()->optionsName . '_maxWidth', 0)); ?>" relHeight="<?php echo intval(get_theme_mod(FT_scope::tool()->optionsName . '_maxHeight', 0)); ?>" id="ft_logo" src="<?php echo get_theme_mod(FT_scope::tool()->optionsName . '_logo', ''); ?>" alt="" /></a>
<?php } else { ?>
<h1 class="site-title logo"><a id="blogname" rel="home" href="<?php bloginfo('siteurl');?>/" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
<?php } ?>
</div>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse navbar-right">
<?php /* Primary navigation */
wp_nav_menu( array(
'menu' => 'top_menu',
'depth' => 2,
'container' => false,
'menu_class' => 'nav navbar-nav',
//Process nav menu using our custom nav walker
'walker' => new wp_bootstrap_navwalker())
);
?>
</div>
</nav>
<div class="row">
<div class="col-md-12 col-xs-12">
<h1>content</h1>
</div>
</div>
</header>