I am writing a "till" app that has a load of buttons. Layout is fine so long as the button value doesn't wrap. If it is wrapped onto a new line, the margins between the buttons screw up.
(If there is only a single line of text, they butt up nicely.)
The buttons are generated by looping through a collection of custom "drink" objects:
foreach (drink d in drinks)
{
buttons = buttons + "<input id='" + d.drinkID + "' class='drinkButton " + d.cssClass + "' type='button' value='" + d.name + "' />";
if ((d.drinkID == 13) || (d.drinkID == 41))
{
buttons = buttons + "<input id='0' class='drinkButton spacer' disabled='disabled' type='button' value='' />";
}
if (d.drinkID == 17)
{
buttons = buttons + "<input id='0' class='drinkButton spacer' disabled='disabled' type='button' value='' /><input id='0' class='drinkButton spacer' disabled='disabled' type='button' value='' />";
}
}
And the css is as follows:
input.drinkButton
{
width:94px;
height: 67px;
font-size:1em;
margin: 0px 6px 6px 0px;
font-weight:normal;
white-space: normal;
padding: 0px;
}
How do I make them line up properly?
If the HTML line break is not working — especially if you're working in the text editor of a CMS like WordPress — then you may be using the element incorrectly. The most common misuse of the new line HTML tag is using it for presentation purposes. For virtually anything related to layout, you should use CSS instead.
The easiest way to have a line break is using the <br> tag on your text. It is used for inserting a single line break.
You are completely right, you don't need comments or line breaks. As long as you use ; at the end of the property. Please look into PHP Minify where you can have full CSS, JS and HTML with line breaks or however you want them to be readable.
To create line breaks in HTML, use the <br> tag. There is no closing tag necessary. In the code above, there will be a line break between "125 N 6th St" and "Brooklyn, NY 11249" that won't have the outrageous amount of space that appears between two paragraph elements. It'll just be a nice line break!
oh how i hate these little bugs/issues.
of the top of my head, is it a vertical-align issue?.
--EDIT--
yep, vertical-align... try top/bottom vertical-align and then see...
input.drinkButton
{
width:94px;
height: 67px;
font-size:1em;
margin: 0px 6px 6px 0px;
font-weight:normal;
white-space: normal;
padding: 0px;
vertical-align:bottom;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With