带有多个嵌入式表格的HTML表单,页面顶部有很多空白区域

时间:2013-10-27 20:34:20

标签: php html forms html-table

我遇到的问题是我试图在.php

中执行的操作

我在表单中使用表来格式化表单的外观。表单工作正常。但是当我加载页面时,页面顶部有一个巨大的空白区域,但我不知道它为什么存在。我试过在Web浏览器中查看源代码,并且没有html空白字符或任何不寻常的东西。这是我的代码:

<?php
$strRequester  = $_SERVER['PHP_SELF'];
echo "<div align=center>\n";
echo "<form name='SandwichOrder' action='$strRequester' method='POST'>\n";
####Bread####
echo "<table>\n";
echo "<tr><td bgcolor='CCCCCC'><input type='radio' name='size' value='whole'><b>Whole Sandwich</b></td>\n";
echo "<td bgcolor='CCCCCC'><input type='radio' name='size' value='half'><b>Half Sandwich</b></td></tr>\n";
echo "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n";
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Roll/Bread:</b></td><td></td></tr><br>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='whiteroll'>White French Roll</td><br>\n";
echo "<td><input type='radio' name='bread' value='sourroll'>Sour Dough Roll</td><br>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='wheatroll'>Wheat French Roll</td><br>\n";
echo "<td><input type='radio' name='bread' value='dutchcrunch'>Dutch Crunch</td><br>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='nyrye'>New York Rye</td>\n";
echo "<td><input type='radio' name='bread' value='soursliced'>Sour Dough Bread</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='bread' value='wheatsliced'>100% Whole Wheat Bread</td>\n";
echo "</tr>\n";
####Meat####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Meat:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='roastbeef'>Roast Beef</td>\n";
echo "<td><input type='radio' name='meat' value='turkey'>Turkey</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='everroastchicken'>EverRoast Chicken</td>\n";
echo "<td><input type='radio' name='meat' value='ham'>Ham</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='salami'>Salami</td>\n";
echo "<td><input type='radio' name='meat' value='pastrami'>Pastrami</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='tune'>Tuna</td>\n";
echo "<td><input type='radio' name='meat' value='chickensalad'>Chicken Salad\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='meat' value='veggiepatty'>Veggie Patty</td>\n";
echo "<td><input type='radio' name='meat' value='vegetarian'>Vegetarian</td>\n";
echo "</tr>\n";
####Cheese####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Cheese:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='cheese' value='cheddar'>Cheddar Cheese</td>\n";
echo "<td><input type='radio' name='cheese' value='swiss'>Swiss Cheese</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='cheese' value='pepperjack'>Pepper Jack Cheese</td>\n";
echo "<td><input type='radio' name='cheese' value='american'>American Cheese</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='radio' name='cheese' value='provolone'>Provolone Cheese</td>\n";
echo "<td><input type='radio' name='cheese' value='none'>No Cheese</td>\n";
echo "</tr>\n";
####Condiments####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Your Condiments:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='mayonnaise' value='mayonnaise'>Add Mayonnaise</td>\n";
echo "<td><input type='checkbox' name='mustard' value='mustard'>Add Mustard</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='lettuce' value='lettuce'>Add Lettuce</td>\n";
echo "<td><input type='checkbox' name='pickles' value='pickles'>Add Pickles</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='tomato' value='tomato'>Add Tomato</td>\n";
echo "<td><input type='checkbox' name='peppers' value='peppers'>Add Peppers</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='onion' value='onion'>Add Onion</td>\n";
echo "<td><input type='checkbox' name='olives' value='olives'>Add Olives</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='salt' value='salt'>Add Salt</td>\n";
echo "<td><input type='checkbox' name='suboil' value='suboil'>Add Sub Oil</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='pepper' value='pepper'>Add Pepper</td>\n";
echo "<td><input type='checkbox' name='avocado' value='avocado'>Add Avocado $0.50</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='sprouts' value='sprouts'>Add Sprouts $0.50</td>\n";
echo "</tr>\n";
####Extras####
echo "<tr><td bgcolor='CCCCCC'><b>Choose Extra Meat or Cheese:</b></td><td></td></tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eroastbeef' value='eroastbeef'>Extra Roast Beef $1.00</td>\n";
echo "<td><input type='checkbox' name='eturkey' value='eturkey'>Extra Turkey $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eeverroastchicken' value='eeverroastchicken'>Extra EverRoast Chicken $1.00</td>\n";
echo "<td><input type='checkbox' name='eham' value='eham'>Extra Ham $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='esalami' value='esalami'>Extra Salami $1.00</td>\n";
echo "<td><input type='checkbox' name='epastrami' value='epastrami'>Extra Pastrami $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='etuna' value='etuna'>Extra Tuna $1.00</td>\n";
echo "<td><input type='checkbox' name='echickensalad' value='echickensalad'>Extra Chicken Salad $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='ebacon' value='ebacon'>Extra Bacon $1.00</td>\n";
echo "<td><input type='checkbox' name='eveggiepatty' value='eveggiepatty'>Extra Veggie Patty $1.00</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='evegetarian' value='evegetarian'>Extra Vegetarian $1.00</td>\n";
echo "<td><input type='checkbox' name='echeddar' value='echeddar'>Extra Cheddar $0.50</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eamerican' value='eamerican'>Extra American $0.50</td>\n";
echo "<td><input type='checkbox' name='eswiss' value='eswiss'>Extra Swiss Cheese $0.50</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td><input type='checkbox' name='eprovolone' value='eprovolone'>Extra Provolone Cheese $0.50</td>\n";
echo "<td><input type='checkbox' name='epepperjack' value='epepperjack'>Extra Pepper Jack Cheese $0.50</td>\n";
echo "</tr>\n";
echo "</table>\n";
####Name/Instructions####
echo "<b>Add your Name or Special Instructions</b><br>\n";
echo "<input type='text' name='instructions' value='' size='50'><br>\n";
echo "<input type='SUBMIT' name='SUBMIT' value='Add to Order'><br>\n";
echo "<input type='button' name='CANCEL' value='Cancel Item'>\n";
echo "</form>";
echo "</div>\n";
?>

我也尝试将整个表单放入表中,但这也没有帮助。任何建议都会很棒。我对.php和html相当新,所以我甚至不知道从哪里开始,在解决这个问题时遇到了麻烦。

1 个答案:

答案 0 :(得分:1)

您是否将表单回显为html文档?即

<!doctype html>
<html>
<head>
<title>Title of the document</title>
</head>

<body>
 YOUR FORM HERE
</body>

</html>

http://www.w3schools.com/tags/tag_body.asp

您的div或html上可能存在默认样式。在你的css尝试:

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
}

div {
   margin: 0;
}