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%;
}
#nick input {
border: 0;
padding: 10px;
width: 10%;
background: #00f;
}
#nick button {
border: 0;
padding: 10px;
width: 10%;
background: rgb(130, 224, 255);
}
#msg {
width: 80%;
}
#msg input {
border: 0;
padding: 10px;
width: 60%;
}
#msg button {
border: 0;
padding: 10px;
width: 10%;
background: rgb(130, 224, 255);
}
#messages {
margin: 0;
padding: 0;
list-style-type: none;
background: #fff;
}
<ul id="messages">
<li>msg</li>
<li>msg</li>
<li>msg</li>
<li>msg</li>
<li>end</li>
</ul>
<div id='nick_msg'>
<form id='nick' action="">
<input id="n" /><button>Join</button>
</form>
<form id='msg' action="">
<input id="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.5em 0 -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?"