Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiline HTML input button with line break adds unwanted margin

Tags:

css

button

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.

enter image description here

(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?

like image 587
Ben Avatar asked Jun 05 '12 20:06

Ben


People also ask

Why is my line break not working in HTML?

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.

How do I insert a line break in button text?

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.

Do line breaks matter in CSS?

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.

How do you break a single line paragraph into two lines in HTML?

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!


1 Answers

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;
}
like image 135
Angry 84 Avatar answered Sep 30 '22 06:09

Angry 84