CJ Catalano
CJ Catalano

Reputation: 97

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?

Upvotes: 0

Views: 2197

Answers (3)

MichaelJTaylor
MichaelJTaylor

Reputation: 344

You can add transparent borders for each <li> like this:

.nav-pills.nav-justified li {
	border-right : 20px solid rgba(255, 255, 255, 0.00);
}
.nav-pills.nav-justified li:last-child {
	border-right-width : 0px;
}

Upvotes: 0

JirkaV
JirkaV

Reputation: 1013

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.

Upvotes: 3

iurii
iurii

Reputation: 4230

try to add the following styles

@media (min-width: 768px) {
  .nav-justified > li {
    padding-right: 15px;
    padding-left: 15px;
  }
}

Upvotes: 0

Related Questions