Reputation: 67898
I want to display four buttons, inline, without any spacing between them. I have a jsfiddle that shows the current behavior. In short, the following HTML/CSS:
<div>
<input id="unconfirmedYes" type="button" value="10%" />
<input id="confirmedYes" type="button" value="98% YES" />
<input id="confirmedNo" type="button" value="2% NO" />
<input id="unconfirmedNo" type="button" value="90%" />
</div>
div input[type=button] {
display: inline;
margin: 0;
padding: 0;
}
#unconfirmedYes, #unconfirmedNo {
width: 10%;
}
#confirmedYes, #confirmedNo {
width: 40%;
}
will in fact line the buttons up, but there is still spacing between them. How do I get rid of that spacing so they stack up right against each other?
Upvotes: 2
Views: 104
Reputation: 2631
Simply use html comments to remove space between html tags.
<div>
<input id="unconfirmedYes" type="button" value="10><!--
--><input id="confirmedYes" type="button" value="98% YES" /><!--
--><input id="confirmedNo" type="button" value="2% NO" /><!--
--><input id="unconfirmedNo" type="button" value="90%" />
</div>
Upvotes: 1
Reputation: 3870
it is assuming that the there are whitespaces between the buttons. If you set font size to zero, the space will be removed.
div.give-it-a-class{
font-size: 0;
}
Detail can be found in this question.
Upvotes: 1
Reputation: 2822
Set float:left
to button.
div input[type=button] {
display: inline;
margin: 0;
padding: 0;
float:left;
}
Upvotes: 2
Reputation: 361615
The whitespace between the <input/>
elements is where the spacing is coming from. If you remove the line breaks and make the tags completely adjacent the space will disappear.
<div>
<input id="unconfirmedYes" type="button" value="10%"
/><input id="confirmedYes" type="button" value="98% YES"
/><input id="confirmedNo" type="button" value="2% NO"
/><input id="unconfirmedNo" type="button" value="90%" />
</div>
Upvotes: 7