Why Do I Get A Gap Between Last Element In One Form And First Element In Second Form?
I have this html file: Now, I get a gap between '#nick button' and '#msg input' like shown in this screenshot: So, I made the content window exactly 1000px and took a look at the
Solution 1:
Set font-size: 0
to your form
and see the magic!
Well, this is due to the characteristic space between elements when using inline elements - note that you have given display: inline
to your form
.
The browser styles for the form
elements will override the zero font-size or you can do it yourself using font-size: initial
.
See demo below:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin: 0;
background: #ff5;
}
form {
display: inline;
font-size: 0;
}
#nick_msg {
background: #000;
position: fixed;
bottom: 0;
width: 90%;
}
#nick {
width: 20%;
}
#nickinput {
border: 0;
padding: 10px;
width: 10%;
background: #00f;
}
#nickbutton {
border: 0;
padding: 10px;
width: 10%;
background: rgb(130, 224, 255);
}
#msg {
width: 80%;
}
#msginput {
border: 0;
padding: 10px;
width: 60%;
}
#msgbutton {
border: 0;
padding: 10px;
width: 10%;
background: rgb(130, 224, 255);
}
#messages {
margin: 0;
padding: 0;
list-style-type: none;
background: #fff;
}
<ulid="messages"><li>msg</li><li>msg</li><li>msg</li><li>msg</li><li>end</li></ul><divid='nick_msg'><formid='nick'action=""><inputid="n" /><button>Join</button></form><formid='msg'action=""><inputid="m"autocomplete="off" /><button>Send</button></form></div>
Solution 2:
I've copied the code here and I think (but I'm not sure), if you're talking about the black little vertical line, you have to add the font-size: 0;
to form
styling.
form {
display: inline;
font-size: 0;
}
Try and tell us
Solution 3:
you might want to add change your the add a margin property in the CSS for your form.
form {
display: inline;
margin: 0 -0.5em0 -0.5em;
}
That should get rid of the space between the forms on the left and right (since your forms are on the same line). Hope this helps :)
Post a Comment for "Why Do I Get A Gap Between Last Element In One Form And First Element In Second Form?"