在输入表单上居中文本
Posted
技术标签:
【中文标题】在输入表单上居中文本【英文标题】:Centering text on Input Form 【发布时间】:2019-02-19 22:54:30 【问题描述】:我搜索了论坛,但找不到可能是一个简单问题的答案。我有一个表格,可以将标题行的文本居中,但不能在后续的“输入”行中居中文本。我尝试过使用 CSS(虽然不是很熟练)。代码如下。有人可以帮忙吗?
$a = array("1","2","3","4","5","6","7","8","9","10");
$b = array("4","5","4","3","4","5","3","4","4","3");
$form = "<form method=\"post\">";
$form .= "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\"> ";
$form .= "<tr>";
$form .= "<td width = \"10\" align = \"center\">A</td> ";
$form .= "<td width = \"10\" align = \"center\">B</td> ";
$form .= "</tr>";
for ($i = 0; $i <= 9; $i++)
$form .= "<tr>";
$val = "t_".$i;
$val1 = $a[$i];
$form .= "<td width = \"10\" align = \"center\"><input type=\"text\" ";
$form .= "name=".$val." value = ".$val1." readonly></td> ";
$val2 = "v_".$i;
$val3 = $b[$i];
$form .= "<td width=\"10\" align =\"center\"><input type=\"text\" ";
$form .= "name=".$val2." value = ".$val3." readonly></td> ";
$form .= "</tr>";
$form .= "</table>";
$form .= "</form>";
echo ($form);
【问题讨论】:
<td width="10" style="text-align:center"><input ...
?
【参考方案1】:
你可以这样做 -
$form.="<td width=\"10\" align =\"center\"><input type=\"text\" ";
$form.= "name=".$val2." value = ".$val3." readonly style='text-align: center;'></td> ";
【讨论】:
以上是关于在输入表单上居中文本的主要内容,如果未能解决你的问题,请参考以下文章