-2

I want no space between the input elements. I tried to remove the margin from the button but nothing changed.

.form{
  float: left;
  margin-top:12px;
  margin-left: 30px;
}
.input-search{
  width:300px;
}
.input-search-button{
  margin:0px;
  padding: 0px;
  width: 15px;
  height: 21px;
}

    
<form class="form" action="" method="get" accept-charset="utf-8">
  <input class="input-search" type="text" name="">
  <input class="input-search-button" type="button" name="">
</form>
Terminator-Barbapapa
  • 3,063
  • 2
  • 5
  • 16
Oronce SOSSOU
  • 13
  • 1
  • 3

3 Answers3

-1

How about using flex on parent element?

.form {
  display: flex;
}
<form class="form" action="" method="get" accept-charset="utf-8">
    <input type="text">
    <input type="button">
</form>
-1

Are you wanting the input fields to stack or be inline? If you want them inline/side-by-side, you can float your input elements. If you use floats, I'd recommend researching clearfix classes if you are unfamiliar.

If you want to stack them, something to keep in mind is that any spaces or line breaks between HTML elements will be rendered based off the font size:

Has Space
--
<div class="block-1">1</div>
<div class="block-2">2</div>

No Spaces
--
<div class="block-1">1</div><div class="block-2">2</div>

Obviously the 2nd HTML option here really isn't preferred, so we can use the following CSS:

.form {
    font-size: 0;
}

.form input {
    font-size: 14px;
}
mdurchholz
  • 523
  • 1
  • 4
  • 16
-1

Check this out:

CSS

.form {
  float: left;
  margin-top: 12px;
  margin-left: 30px;
  display: flex;
}
.input-search {
  width: 300px;
  padding-right: 15px;
}
.input-search-button {
  margin: 0px;
  padding: 0px;
  width: 15px;
  height: 21px;
  transform: translateX(-15px);
}
kuroyza
  • 332
  • 1
  • 5
  • 12