我正在编写一个带有大量按钮的“直到”应用程序。只要按钮值不换行,布局就很好。如果它被换行,则按钮之间的边距会变大。
(如果只有一行文本,它们会很好地对接。)
这些按钮是通过循环自定义“drink”对象的集合生成的:
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='' />";
}
}
CSS如下:
input.drinkButton
{
width:94px;
height: 67px;
font-size:1em;
margin: 0px 6px 6px 0px;
font-weight:normal;
white-space: normal;
padding: 0px;
}
如何让它们正确排列?