表格在Firefox和Chrome中消失

时间:2012-05-04 13:12:36

标签: html css html-table

我有一张桌子,当我在Firefox或Chrome中加载页面时,它从屏幕向右移动导致大部分桌子消失,桌子应位于屏幕中间并且似乎重叠在页面区域的右侧。

<html lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Small North Run</title>
<meta name="description" content=" ">
<meta name="keywords" content=" ">
<link rel="stylesheet" href="default.css" type="text/css">
<link rel="stylesheet" href="sponsor.css" type="text/css">

</head>

<body>

<div id="wrapper">

<header>
    <h1>SMALL NORTH RUN</h1>
</header>

<nav>
<ul id="navlist">
    <li><a href="./">HOME</a></li>
    <li><a href="training">TRAINING REGIME</a></li>
    <li><a href="./forum">FORUM</a></li>
    <li><a href="./sponsor.php">SPONSOR</a></li>
    <li><a href="./contact.php">CONTACT</a></li>
</ul>
</nav>
<hr id="hrnav" />

<div id="content">

<p>This page allows you to sponsor a particular runner. Just simply select the name of the runner you wish to sponsor from the drop down list, then enter the amount you wish to donate followed by a brief message for the runner and then your name. Once making a donation the runner you have sponsored will be notified by email that you have made a donation.</p>
<br/>
<br/>
<br/>
<br/>
<form method="post" action="test.php">
<table>

    <tr><td><label>Runner:</label></td>
    <td>
    <select name="fullname">
    <?php do{?>
    <option value="<?php echo $rsNames['user_ID']; ?>"> <?php echo $rsNames['first_Name'];?> <?php echo $rsNames['last_Name'];?></option>
    <?php } while ( $rsNames= mysql_fetch_assoc($names_query))?>
    </select>
    </td>
    </tr>
    <tr><td><label>Donation (£):</label></td><td><input type="text" maxlength="9" value="0.00" name="donation"/></td></tr>
    <tr>
    <td>
        <label>Message:</label>
    </td>
    <td>
        <textarea  name="donationmessage" maxlength="200" cols="25" rows="6"> </textarea>
    </td>
    </tr>
        </tr>
    <tr><td><label>Your Name:</label></td><td><input type="text" maxlength="30"  name="donator"/></td></tr>
    <tr>
    <td>
    <tr><td><input id="submit" type="submit" value="Confirm Donation"/></td></tr>
    </table>
</form>


</div>



</div> <!-- END WRAPPER -->

</body>

</html>

CSS
#content { text-align: left; margin: 2px; padding: 10px; }

#content p { font: font: 12px/1.5 Verdana, sans-serif; float: left; }

3 个答案:

答案 0 :(得分:1)

尝试添加doctype:

例如,这是HTML5 doctype

<!DOCTYPE html>

答案 1 :(得分:0)

这对我来说似乎很好。

也许你的css有问题?

编辑: P标签上的浮动样式造成了麻烦。

一个简单的解决方案可能是在P标签下使用defloating-break-div(我不确定名称是什么):

<div style="float:none;">
     <br />
</div>

这会导致其余代码恢复正常布局

答案 2 :(得分:0)

1)表格结构中存在一些错误

2)如果你需要居中表,你可以设置margin-left和margin-right auto。

可能有对齐的表格代码:

<table style='margin: 0 auto;'>
<tr>
        <td><label>Runner:</label></td>
        <td>
<select name="fullname">
<?php do{?>
<option value="<?php echo $rsNames['user_ID']; ?>"> <?php echo $rsNames['first_Name'];?> <?php echo $rsNames['last_Name'];?></option>
<?php } while ( $rsNames= mysql_fetch_assoc($names_query))?>
</select>
     </td>
</tr>
<tr>
        <td><label>Donation (£):</label></td>
        <td><input type="text" maxlength="9" value="0.00" name="donation"/></td>
</tr>
<tr>
        <td><label>Message:</label></td>
        <td><textarea  name="donationmessage" maxlength="200" cols="25" rows="6"> </textarea></td>
</tr>
<tr>
        <td><label>Your Name:</label></td>
        <td><input type="text" maxlength="30"  name="donator"/></td>
</tr>
<tr>
        <td><input id="submit" type="submit" value="Confirm Donation"/></td>
        <td>&nbsp;</td>
</tr></table>

如果您仍然遇到麻烦:在某处发布完整的HTML和CSS代码以进行详细分析。