As I work on crafting a navigation bar using flex-box and Bootstrap 4, I encountered an issue where two of the divs, header__center
and header__right
, were wrapping onto separate lines when the browser window size shrunk. However, my goal is to keep them aligned on the same line regardless of the device's width.
The problem arises when the device width falls within the range of 576
to 614
:
https://i.sstatic.net/UrYCE.png
And another issue occurs when the device's size is extra small, less than 314
:
https://i.sstatic.net/P7Jhu.png
* {
margin: 0;
padding: 0;
}
nav.navbar {
align-content: center;
position: sticky;
background-color: white;
z-index: 100;
top: 0;
box-shadow: 0px 5px 8px -9px rgba(0, 0, 0, 75);
padding: 0px 20px;
/* REMOVED TOP PADDING */
}
.fas .fa-search {
color: #65676b;
}
.... (remaining CSS code herein)
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" />
<nav class="navbar navbar-light bg-light py-xl-0 py-md-0 py-sm-0 py-2">
... (rest of HTML code goes here)
I am seeking guidance on how to ensure that these icons remain on the same line and adapt responsively to varying device widths. Any insights or assistance would be greatly appreciated!
I am considering using media queries to address this issue but could use suggestions on how to approach implementing techniques to keep the icons aligned on the same line.