Removing the space between the input field and button in a search bar
I think the input-group-btn or input-group-text(made-up name for search textarea) has non-zero margins between them, so make them zero, and try enclosing them in a div and then apply same margins for the enclosing div.
How to remove the space between Text Input and Submit Button?
Simply put them together :)
<label>
<span class="screen-reader-text">Search for:</span>
<input type="search" class="search-field" placeholder="Search up in hur" value="" name="s" title="Search for:" /></label><input type="submit" class="search-submit" value="Search" />
Extra space when input and button are next to each other
The space is there because a line jump (return) is considered a white space. To avoid this you can:
- Put the
input
andbutton
tags right next to each other (harder to read your code) - Use the "comment hack" where you'd write your code with a
<!--
right after the<input>
and-->
right before the<button>
. - Use
display: flex
on your form to avoid the whitespace being rendered.
For your button positioning issue, it's related to the alignment on the baseline. vertical-align: bottom;
on your button will fix this.
See the solution on this Fiddle
remove gap between input and button
You can put your html content inline. That will remove the space without having margin-left as negative
<input class="txt" type="text" name="name"><button class="btn">Submit</button>
Also to put them align in a horizontal row, you need to consider giving some less % to input.
Demo - http://jsfiddle.net/RahulB007/rm9etsny/5/
How to remove the extra space between label and input?
The only way to tackle this issue is by setting margin or padding to the two elements.
I would advise you to set padding & margin 0 for both label and input and if you still want to reduce the gap, sometimes you will probably need to set a negative margin which is not recommended but still does the job.
try this on your label
.label {
/*margin-bottom: -5px;*/
margin-bottom: 0px
}
In HTML
<label class="lable">...</label>
Again, this practice of adding a negative margin is highly discouraged.
EDIT: I missed the display:inline-block property, which someone in comments reminded me of
Above fix won't work, Making margin-bottom: 0 for the label will work though
a js fiddle:
* {
list-style: none;
text-decoration: none;
box-sizing: border-box;
}
.container {
width: 80%;
margin: auto;
}
aside#sidebar-wrapper {
padding: 5px;
width: 300px;
border: 2px black solid;
}
aside#sidebar-wrapper input {
width: 100%;
}
.lable {
margin-bottom: 0px;
}
<div class="container">
<aside id="sidebar-wrapper">
<h1>Get A Quote</h1>
<form action="" class="form-sidebar-wrapper">
<div class="sidebar-input-wrapper">
<label class="lable">Name</label>
<input type="text" placeholder="Name" class="nameINput">
</div>
<div class="sidebar-input-wrapper">
<label class="lable">Email</label>
<input type="email" placeholder="Enter Email">
</div>
<button type="submit" class="button_1">Send</button>
</form>
</aside>
</div>
how to change space with - in search bar input
I created a jsfiddle - which should work.
So what it is doing:
If a person is triggering the keypress event and the character typed is a space (char 32) I prevent the event and instead get the current value of the field and add a dash -
.
What it is not doing:
If someone is pasting text, there is no keypress event and therefore no replacing of the space character.
Related Topics
How to Set Filename for Base64 Rendered Pdf Using Object Tag
Setting Attribute Disabled on a Span Element Does Not Prevent Click Events
Playing M3U8 Files With HTML Video Tag
How to Disable Auto-Play for Local Video in Iframe
How Can the Parent Div Auto Resize Its Height Based on the Child'S Height
Make a Div Fill the Height of the Remaining Screen Space
Maintain the Aspect Ratio of a Div With Css
How to Vertically Center Text With Css
How to Lock Viewport to Portrait Orientation in Html5/Css3
How to Get an Iframe to Be Responsive in iOS Safari
Maxlength Ignored for Input Type="Number" in Chrome
How to Set Textarea to 100% Width and Height
Displaying Comma Separated String in Angular 6
Moving an Image Across a HTML Canvas
How to Make Transparent Color White Instead of Black in Html2Canvas
Htmlspecialchars() Expects Parameter 1 to Be String Array Given