HTML中心对齐不在表单中工作

时间:2015-07-29 05:58:07

标签: php html forms

您好我正在开发一个表单,让用户通过PayPal支付项目费用。除了显示3个项目的下拉菜单外,我能够将所有内容都集中在一起。明星,日志和回合。

有人帮我解释为什么它不起作用?三江源。

<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_top'>");
echo("<input type='hidden' name='cmd' value='_xclick'>");
echo("<input type='hidden' name='business' value='petjul@iprimus.com.au'>");
echo("<input type='hidden' name='lc' value='AUD'>");
echo("<input type='hidden' name='item_name' value='Christmas Cakes'>");
echo("<input type='hidden' name='button_subtype' value='services'>");
echo("<input type='hidden' name='no_note' value='0'>");
echo("<input type='hidden' name='currency_code' value='AUD'>");
echo("<input type='hidden' name='bn' value='PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest'>");
echo("<table>");
echo("<center>");
echo("<tr><td><input type='hidden' name='on0' value='Cakes'><center>Purchase Order Through Paypal / Credit Card</center></td></tr><tr><td><select name='os0' align='center'>");
    echo("<center><option value='Star'>Star $15.00 AUD</option></center>");
    echo("<center><option value='Log'>Log $25.00 AUD</option></center>");
    echo("<center><option value='Round'>Round $60.00 AUD</option></center>");
echo("</select> </td></tr>");
echo("</center>");
echo("</table>");
echo("<input type='hidden' name='currency_code' value='AUD'>");
echo("<input type='hidden' name='option_select0' value='Star'>");
echo("<input type='hidden' name='option_amount0' value='15.00'>");
echo("<input type='hidden' name='option_select1' value='Log'>");
echo("<input type='hidden' name='option_amount1' value='25.00'>");
echo("<input type='hidden' name='option_select2' value='Round'>");
echo("<input type='hidden' name='option_amount2' value='60.00'>");
echo("<input type='hidden' name='option_index' value='0'>");
echo("<input type='image' src='https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif' border='0' name='submit' alt='PayPal - The safer, easier way to pay online!'>");
echo("<img alt='' border='0' src='https://www.paypalobjects.com/en_US/i/scr/pixel.gif' width='1' height='1'>
</form>");

3 个答案:

答案 0 :(得分:1)

有冲突 <?php ?>HTML

<center>中不支持

HTML 5。因此,您可以将text-align: center<span>代码一起使用。(<span style='text-align: center'>

所以最后的答案是

echo("<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_top'>");
echo("<input type='hidden' name='cmd' value='_xclick'>");
echo("<input type='hidden' name='business' value='petjul@iprimus.com.au'>");
echo("<input type='hidden' name='lc' value='AUD'>");
echo("<input type='hidden' name='item_name' value='Christmas Cakes'>");
echo("<input type='hidden' name='button_subtype' value='services'>");
echo("<input type='hidden' name='no_note' value='0'>");
echo("<input type='hidden' name='currency_code' value='AUD'>");
echo("<input type='hidden' name='bn' value='PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest'>");
echo("<table>");
echo("<tr><td><input type='hidden' name='on0' value='Cakes'><span style='text-align: center'>Purchase Order Through Paypal / Credit Card</span></td></tr><tr><td><select name='os0' align='center'>");
echo("<tr><td><input type='hidden' name='on0' value='Cakes'><span style='text-align: center'>Purchase Order Through Paypal / Credit Card</span></td></tr><tr><td><select name='os0' align='center'>");
echo("<span style='text-align: center'><option value='Star'>Star $15.00 AUD</option></span>");
echo("<span style='text-align: center'><option value='Log'>Log $25.00 AUD</option></span>");
echo("<span style='text-align: center'><option value='Round'>Round $60.00 AUD</option></span>");
echo("</select> </td></tr>");
echo("</table>");
echo("<input type='hidden' name='currency_code' value='AUD'>");
echo("<input type='hidden' name='option_select0' value='Star'>");
echo("<input type='hidden' name='option_amount0' value='15.00'>");
echo("<input type='hidden' name='option_select1' value='Log'>");
echo("<input type='hidden' name='option_amount1' value='25.00'>");
echo("<input type='hidden' name='option_select2' value='Round'>");
echo("<input type='hidden' name='option_amount2' value='60.00'>");
echo("<input type='hidden' name='option_index' value='0'>");
echo("<input type='image' src='https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif' border='0' name='submit' alt='PayPal - The safer, easier way to pay online!'>");
echo("<img alt='' border='0' src='https://www.paypalobjects.com/en_US/i/scr/pixel.gif' width='1' height='1'>");
echo("</form>");

答案 1 :(得分:0)

您可以尝试将它放在div上:

echo('<div align="center">');
  Your code here.
echo('</div>');

对于HTML5,您可以使用:

echo('<div style="text-align:center">');
  Your code here.
echo('</div>');

答案 2 :(得分:0)

参见工作示例here

select {
 width: 100%;
 text-align: center;
 padding-left: 50%;
}