I am trying to use HTML and CSS create a search box with a text input tag and a button input tag both centered within it. But the CSS code does not work to my button tag though it works to the other tag.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
input {
outline: none;
}
.search-box {
height: 50px;
width: 280px;
border: 1px solid #DCDCDC;
background-color: #F5F5F5;
margin: 10px auto;
border-radius: 10px;
box-shadow: 2px 2px 1px #D3D3D3, -2px 2px 1px #D3D3D3;
}
#input-search {
width: 200px;
height: 30px;
border: 1px solid #DCDCDC;
margin: 9px 10px 9px 9px;
border-radius: 5px;
text-indent: 3px;
}
#btn {
height: 30px;
width: 50px;
font-size: 12px;
font-weight: 600;
color: #fff;
border-radius: 5px;
border: 1px solid #008080;
display: inline-block;
margin: 9px 9px 9px 0;
background-image: linear-gradient(#20B2AA, #5F9EA0);
}
<div class="search-box">
<input type="text" id="input-search" placeholder="search">
<input type="button" value="GO" id="btn">
</div>
Based on my calculation, the margin on both sides is supposed to make the two tags perfectly centred in the div, but there seems to be some padding or margin which *{margin:0; padding:0;box-sizing:border-box;} cannot clear.
The button cannot be either centered vertically or be displayed in line with the text tag.Can anyone please help me fix the button tag?
Here is the full code: https://codepen.io/mayiscoding/pen/qBxLbYb