Search code examples
twitter-bootstrapnavnav-pills

bootstrap justified nav - how to space items?


I'm using the following bootstrap navbar:

<nav class="navbar navbar-default">
			<div class="container-fluid">
				<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				</div>
				<div id="navbar" class="navbar-collapse collapse">
					<ul class="nav nav-pills nav-justified">
						<li><a href="#">Home</a></li>
						<li><a href="#">Readings</a></li>
						<li><a href="#">Workshops</a></li>
						<li><a href="#">Aligning</a></li>
						<li><a href="#">Yoga</a></li>
						<li><a href="#">Shop</a></li>
						<li><a href="#">Contact</a></li>
					</ul>
				</div><!--/.nav-collapse -->
			</div><!-- container-fluid -->
        </nav>

It works as intended, but I'd like to add some space between the 'buttons'. I can't seem to find a way to either add padding or margin to the li's so that they space out a little. Any suggestions?


Solution

  • I assume that you already solved this somehow. But in case that someone will arrive here.

    The problem is, that Bootstrap uses display: table-cell for the .nav-justified > li element.

    @media (min-width: 768px)
    .nav-justified>li {
        display: table-cell;
        width: 1%;
    }      
    

    So instead of margin or padding you need to use border-spacing. Simply extend the Bootstrap in your own style:

    .nav-justified {
       border-collapse:separate;
       border-spacing:5px;
    }
    

    See this thread if you need more information.