Your margin-bottom style is not defined in the input.
The input appears "tall" due to a font size of 14px and an input height of 35px.
To adjust, consider reducing the height, adding padding, and incorporating an event listener.
document.getElementById("location").addEventListener("keyup", function(){
if (this.value != '') {
this.style.borderBottomWidth = "0px"
} else {
this.style.borderBottomWidth = "2px"
}
},false)
.car-list-input {
font-family: 'Source Sans Pro', sans-serif;
border: 2px solid #e0e6e8;
border-radius: 3px;
font-size: 14px;
font-weight: 400 !important;
height: 35px;
position: relative;
}
.car-list-input:focus {
border-color: #25c16f;
outline: 0;
box-shadow: none;
border-bottom: solid 2px #25c16f;
}
<input type="text" placeholder="Enter the location of your vehicle" id="location" onchange="locationApproved()" autocomplete="off" class="form-control car-list-input">
You can also add a required
attribute to the input for a pure CSS solution:
.car-list-input {
font-family: 'Source Sans Pro', sans-serif;
border-style: solid;
border-color: #e0e6e8;
border-width: 2px 2px 0 2px;
border-radius: 3px;
font-size: 14px;
font-weight: 400 !important;
height: 35px;
position: relative;
}
.car-list-input:focus {
border-color: #25c16f;
outline: 0;
box-shadow: none;
border-color: #25c16f;
}
.car-list-input:invalid {
border-width:2px;
}
<input type="text" required placeholder="Enter the location of your vehicle" id="location" onchange="locationApproved()" autocomplete="off" class="form-control car-list-input">