'How to horizontally align three items in a navbar?
I am attempting to add the title of my website to the middle of my navbar
but I haven't been able to accomplish my goal.
Here's my code:
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown">
<i class='fas fa-bars' style='color:#66fcf1'></i> <span class='text' style='margin-left:0.5vh'>.menu</span>
</a>
<div class="dropdown-menu text-light animate slideIn">
<a class="dropdown-item" href="#">Články</a>
<a class="dropdown-item" href="#">Kontakt</a>
<a class="dropdown-item" href="#">O nás</a>
</div>
</li>
</ul>
<div class="align-items-center"><h5>infoot<span>.sk</span></h5></div>
<?php
if (!isset($_SESSION['user'])){ ?>
<ul class="nav navbar-nav justify-content-between ml-auto">
<li class="dropdown order-1">
<button type="button" id="dropdownMenu1" data-toggle="dropdown" class="btn btn-outline-secondary dropdown-toggle">Login <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right mt-2">
<li class="px-3 py-2">
<form class="form" role="form" method="post" action="infoot.php">
<div class="form-group">
<input name="meno" id="emailInput" placeholder="Meno" class="form-control form-control-sm" type="text" required="">
</div>
<div class="form-group">
<input name="heslo" id="passwordInput" placeholder="Heslo" class="form-control form-control-sm" type="password" required="">
</div>
<div class="form-group">
<button type="submit" class="btn btn-dark btn-block" name="tlacidlo">Login</button>
</div>
</form>
</li>
</ul>
</li>
<li class="dropdown order-2">
<button type="button" id="dropdownMenu2" data-toggle="dropdown" class="btn btn-outline-secondary dropdown-toggle">Register <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right mt-2">
<li class="px-3 py-2">
<form class="form" role="form" method="post" action="infoot.php">
<div class="form-group">
<input name="meno" id="emailInput" placeholder="Meno" class="form-control form-control-sm" type="text" required="">
</div>
<div class="form-group">
<input name="heslo" id="passwordInput" placeholder="Heslo" class="form-control form-control-sm" type="password" required="">
</div>
<div class="form-group">
<button type="submit" class="btn btn-dark btn-block" name="register">Register</button>
</div>
</form>
</li>
</ul>
</li>
</ul>
<?php }
else{ ?>
<ul class="nav navbar-nav ml-auto align-items-center">
<a class="navbar-brand"><span class='text'>.vitaj, <?php echo $_SESSION['user']; ?></span></a>
<a href="logout.php"><span class="fas fa-sign-out-alt"></span></a>
</ul>
<?php } ?>
</nav>
What I need to align is this:
<div class="align-items-center"><h5>infoot<span>.sk</span></h5></div>
Solution 1:[1]
Wrap a div
inside of another div
, then give it class row, and configure the class using: justify-content-center
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | j D3V |