So this is what bootstrap\'s navbar form looks like.
The default HTML is:
I thought of a minimal way to fix this without modifying the default structure of the navbar form used in the Bootstrap documentation.
Add class navbar-input-group
to the form
CSS (place in media query if necessary):
.navbar-input-group {
font-size: 0px; /*removes whitespace between button and input*/
}
.navbar-input-group input {
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
.navbar-input-group .btn {
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
border-left: 0px;
}
or SCSS (keeps responsiveness intact):
@import "bootstrap-variables";
.navbar-input-group {
@media (min-width: $screen-sm) {
font-size: 0px; /*removes whitespace between button and input*/
input {
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
.btn {
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
border-left: 0px;
}
}
@media (max-width: $screen-xs-max) {
margin-top:0px;
margin-bottom:0px;
.btn {
width:100%;
}
}
}
Result:
For purposes of clarity, I am targeting descendant elements in the CSS. This is not the most efficient way to target CSS elements. If you like this answer, consider giving the input and button unique class names and targeting them without any descendant selectors in your CSS (read: http://csswizardry.com/2011/09/writing-efficient-css-selectors/)