Just starting out with Bootstrap 4 and creating a practice page with a header to familiarize myself with the navbar
system.
I have put together this jsFiddle (full code) for reference, but essentially, my page structure is as follows:
index.html
<nav class="navbar navbar-expand-lg">
<a class="navbar-brand" href="javascript:void(0)">
<img src="https://raw.githubusercontent.com/bitbythecron/bootstrap-troubleshooting/main/dummy-logo.png" class="img-fluid mainlogo" alt="Responsive image">
</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navb">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navb">
<!-- Menu items go here -->
</div>
</nav>
main.css
html, body {
height: 100%;
font-family: 'Lato';
}
.bordered {
border-radius: 5px;
border: 1px solid white;
}
.navbar {
background-color: #00142e;
}
.red-button {
border-radius: 5px;
border: 1px solid #A81E30;
background-color: #A81E30;
color: beige;
}
.mainlogo {
width: 35%;
}
Upon running the code, I encountered some issues:
https://i.sstatic.net/h95eK.png
The main concern is the excessive padding around the navbar. How can I remove this padding and ensure that the navbar's height aligns with the logo and menu links? I tried adding padding: 0px;
to the navbar style, but it had no effect.
Furthermore, I would like to center all the content within the navbar (both logo and menu items). Any suggestions on how I can achieve this? Adding d-flex justify-content-center
to navbar-collapse
did not yield the desired result. Thank you in advance!
Update
I have made changes based on the feedback provided below which resulted in the following layout:
https://i.sstatic.net/BkQTa.png
However, I am still facing issues with centering the navbar content (logo + links) and reducing the unnecessary padding, as the blue bar appears taller than desired. I aim for a more compact design hugging the logo and links closely.