Not Aligning Itself In Center Of Container
, and are all inside one container. I've used align-items-center to align them all in the same line inside the container. However that property is not applying to the tag. What
Solution 1:
Bootstrap 4 paragraphs <p>
have a bottom margin. Use the mb-0
class to remove it.
<p style="padding-right: 0.5em; padding-left: 0.5em;" class="my-0"> or </p>
https://www.codeply.com/go/n337ATFcOh
You could simplify the markup and CSS a lot by utilizing the Bootstrap Navbar or Nav. There is also no reason to use nested containers.
Solution 2:
You have a margin set to p element. Just remove it and you are good to go:
nav ul{
padding: 0;
display: flex;
margin-bottom: 0;
}
nav li{
list-style: none;
padding: 0 0.2em;
}
nav a{
text-decoration: none;
}
#login{
display: inline-block;
min-width: max-content;
max-height: min-content;
margin: 0;
}
nav p {
margin: 0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<nav>
<div class="container d-flex align-items-center justify-content-between ">
<div class="container d-flex align-items-center ">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact Us</a></li>
<li><a href="#">About Us</a></li>
</ul>
</div>
<div class="container-flex d-flex align-items-center">
<a href="#" style="white-space: nowrap">Sign up</a>
<p style="padding-right: 0.5em; padding-left: 0.5em;"> or </p>
<button class="btn btn-success btn-md" id="login">Log in</button>
</div>
</div>
</nav>
Solution 3:
you also use margin-bottom:0
orSolution 4:
.mb-0{margin-bottom:0px;}
<p style="padding-right: 0.5em; padding-left: 0.5em;" class="mb-0"> or </p>
Solution 5:
add margin-top in p tag as below:
nav ul{
padding: 0;
display: flex;
margin-bottom: 0;
}
nav li{
list-style: none;
padding: 0 0.2em;
}
nav a{
text-decoration: none;
}
#login{
display: inline-block;
min-width: max-content;
max-height: min-content;
margin: 0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<nav>
<div class="container d-flex align-items-center justify-content-between ">
<div class="container d-flex align-items-center ">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact Us</a></li>
<li><a href="#">About Us</a></li>
</ul>
</div>
<div class="container-flex d-flex align-items-center">
<a href="#" style="white-space: nowrap">Sign up</a>
<p style="padding-right: 0.5em; padding-left: 0.5em; margin-top: 15px;"> or </p>
<button class="btn btn-success btn-md" id="login">Log in</button>
</div>
</div>
</nav>
Post a Comment for "
Not Aligning Itself In Center Of Container"