While working on a Bootstrap navbar with a search box, I encountered a problem on mobile devices. Everything looks fine at a screen width of 576px or above, but below that, the search icon moves under the input field.
At 576px: https://i.sstatic.net/xWqKv.png
At 550px: https://i.sstatic.net/NpxlV.png
I'm wondering why this is happening and how I can fix it. I've tried multiple solutions without success. I haven't included any media queries for widths below 576px; only for max-width: 992px.
body {
background-color: black !important;
}
.mobile-form {
border: none;
color: #ffffff;
background-color: #292935;
}
.mobile-border {
border-bottom: 1px solid #ffffff;
margin-left: 20px;
margin-right: 20px;
}
.mobile-search-icon {
float: right;
margin-top: 10px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" rel="stylesheet">
<form class="form-inline d-block d-lg-none mobile-border">
<input class="form-control mobile-form" type="search" placeholder="Search our site" aria-label="Search">
<i class="fas fa-search text-white ml-3 mobile-search-icon" aria-hidden="true"></i>
</form>