I've tried experimenting with code from similar questions, but I'm still stuck! I've managed to get 2 flex rows in a flex column with the brand image vertically centered, but I'm struggling with the horizontal spacing.
On the first row of my navbar, I have a list of nav-items and an inline form with a search bar. I want the search bar to be right-aligned while keeping the nav-items left-aligned.
I've tried using justify-content-between and mx-auto classes, but I can't seem to separate the nav-items and search bar horizontally while keeping them on the same row!
Here's my code:
.navbar {
padding-top: 0;
padding-bottom: 0;
font-weight: 300;
}
.navbar-dark {
background: linear-gradient(to right, rgba(0, 45, 165, 0.97), rgba(10, 88, 157, 0.97), rgba(10, 88, 157, 0.97), rgba(0, 45, 165, 0.97);
}
.navbar-brand {
margin-right: 20px;
}
.nav-item {
font-family: 'Raleway', sans-serif;
font-weight: 300;
font-size: 80%;
padding: 0 .4rem;
}
.navbar .navbar-nav .nav-link {
transition: all .05s ease-in-out;
}
.navbar-dark .navbar-nav .nav-link.active {
border-bottom: 1px solid white;
}
.navbar-dark .navbar-nav .nav-link:hover {
border-bottom: 1px solid white;
}
.navbar-toggler:hover {
cursor: pointer;
}
#search-bar {
background-color: #5c87af;
color: white;
font-size: 14px;
width: 200px;
height: 30px;
transition: all .2s;
border: none;
}
#search-bar:hover {
background-color: #779ec1;
}
#search-bar:focus {
background-color: white;
color: #212529;
width: 400px;
}
#search-bar::-webkit-input-placeholder {
color: white !important;
}
#search-bar:-moz-placeholder {
/* Firefox 18- */
color: white !important;
}
#search-bar::-moz-placeholder {
/* Firefox 19+ */
color: white !important;
}
#search-bar::-ms-input-placeholder {
color: white !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.bundle.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar fixed-top navbar-dark navbar-expand-sm">
<a class="navbar-brand" href="#">
<img src="/images/MW-logo-white.png" height=28 class="" />
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse flex-column align-items-start" id="navbar">
<ul class="navbar-nav nav my-1">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#property-tab">PROPERTY</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#units-tab">UNITS</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tenancies-tab">TENANCIES</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#pdfs-tab">PDFs</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#contacts-tab">CONTACTS</a>
</li>
<form class="form-inline">
<input class="form-control search" type="text" id="search-bar" placeholder="Search..." autocomplete="off" spellcheck="false" autocorrect="off" />
</form>
</ul>
<ul class="navbar-nav nav my-1">
<li class="nav-item">
<a href="#" class="nav-link active">ALL</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">CURRENT</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">PAST</a>
</li>
</ul>
</div>
</nav>