为什么我的 html 列这么长?
Why are my html columns so long?
我正在尝试制作一个连接到将保存比赛信息的数据库的网站。
虽然我已将长度设置为 7 个字符,但目前列太长了。
我做错了什么?如何让列的宽度为 7 个字符长?
这是我的代码:
<?php
function table_head()
{
if ( func_num_args() > 0 )
{
$args = func_get_args();
foreach($args as $value)
{
echo "<th>" . $value . "</th>";
}
}
}
function display_fields()
{
$i = 0;
$a = 19;
while($i++ < $a)
{
echo "<td><input type='text' width='7'/></td>";
}
}
echo "<table>";
echo "<col width='7'>";
echo "<tr>";
table_head("Time","lap1","lap2","lap3","lap4","lap5","lap6","lap7","lap8","lap9","lap10","lap11","lap12","lap13","lap14","lap15","lap16","lap17","Avg Spd");
echo "</tr>";
echo "<tr>";
display_fields();
echo "</tr>";
echo "</table>";
?>
我知道我的代码可以更有效率,我会尽快提高它的效率。
您想使用 size
属性而不是 width
。
<input type="text" size="7">
<input>
元素的 width
属性仅在输入类型为 image
时有效。
<!-- Image input -->
<input type="image" width="300">
我正在尝试制作一个连接到将保存比赛信息的数据库的网站。
虽然我已将长度设置为 7 个字符,但目前列太长了。
我做错了什么?如何让列的宽度为 7 个字符长?
这是我的代码:
<?php
function table_head()
{
if ( func_num_args() > 0 )
{
$args = func_get_args();
foreach($args as $value)
{
echo "<th>" . $value . "</th>";
}
}
}
function display_fields()
{
$i = 0;
$a = 19;
while($i++ < $a)
{
echo "<td><input type='text' width='7'/></td>";
}
}
echo "<table>";
echo "<col width='7'>";
echo "<tr>";
table_head("Time","lap1","lap2","lap3","lap4","lap5","lap6","lap7","lap8","lap9","lap10","lap11","lap12","lap13","lap14","lap15","lap16","lap17","Avg Spd");
echo "</tr>";
echo "<tr>";
display_fields();
echo "</tr>";
echo "</table>";
?>
我知道我的代码可以更有效率,我会尽快提高它的效率。
您想使用 size
属性而不是 width
。
<input type="text" size="7">
<input>
元素的 width
属性仅在输入类型为 image
时有效。
<!-- Image input -->
<input type="image" width="300">