页脚不会留在页面底部由于表(Footer wont stay at bottom of page d

2019-11-01 08:21发布

我做一个简单的内容管理系统,我的CSS和布局工作的一切除了我做,然后以某种方式移动页脚部分移动到一个包装排序上面部分的表。 甚至低于表格文本中获取表上面的输出。

我的基本布局...

        <?php
        session_start();
        //nav bar //top part of page which fully works etc
        include "header.php";
    ?>

    <section class= "mainSection">

    <section class = "subMain">
    <p> this should be above </p>

    <?php include "/mysql/catgoryShow.php"; ?>

    <p> this should be below the table </p>

    </section>

    </section>
    <footer class = "mainFooter">

    </footer>

</body>

我的CSS的重要组成部分...

section.mainSection{

margin-left: 4%;
margin-right:4%;
min-height: 1000px;
background-color: #ffffff;

border-left-style:solid;
border-left-color:#DAE3ED;
border-left-width:5px;

border-right-style:solid;
border-right-color:#DAE3ED;
border-right-width:5px;



   }

section.subMain{
margin-left: 10%;
margin-right: 10%;
padding-top:10%;
padding-bottom: 2%;

 }

我的页脚的CSS

footer.mainFooter{

margin-left: 4%;
margin-right:4%;
height: 75px;
background-color:#78B0F0;
border-top-style:solid;
border-top-color:#DAE3ED;
border-top-width:5px;
 }

最后我的表

    <?php
$result=mysql_query($query);

$num=mysql_numrows($result);
    echo "<p>'$query' returns $num rows:<p>\r\n";
?>
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<td><font face="Arial, Helvetica, sans-serif">|Product ID|</font></td>
<td><font face="Arial, Helvetica, sans-serif">|Product Name|</font></td>
<td><font face="Arial, Helvetica, sans-serif">Product Category|</font></td>
<td><font face="Arial, Helvetica, sans-serif">Product Minimum Age|</font></td>
<td><font face="Arial, Helvetica, sans-serif">Product Discription|</font></td>
<td><font face="Arial, Helvetica, sans-serif">Product Price|</font></td>
<td><font face="Arial, Helvetica, sans-serif">Product Quantily Available|</font></td>
<td><font face="Arial, Helvetica, sans-serif">View Product Page|</font></td>
</tr>

<?php
$i=0;
while ($i < $num) {

$f1=mysql_result($result,$i,"ProductID");
$f2=mysql_result($result,$i,"ProductName");
$f3=mysql_result($result,$i,"ProductCategory");
$f4=mysql_result($result,$i,"SuitableAge");
$f5=mysql_result($result,$i,"ProductDiscription");
$f6=mysql_result($result,$i,"ProductPrice");
$f7=mysql_result($result,$i,"ProductAvailable");
?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f6; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f7; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f7; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><a href="../cw/itemPage.php?id=<?php echo $f1?>">View Details</a></font></td>
</tr>

<?php

$i++;
}
   echo "<p>'$query' returns $num rows:<p>\r\n";


?>

无论是显示查询的回声获取表之前印刷莫名其妙藏汉:/

Answer 1:

如前所述之前-你必须关闭该表元素与相应的</table>标记。 在极少数情况下,表也可能会继承一些浮动值,以便footer.mainFooter { clear: both; } footer.mainFooter { clear: both; }应该解决这个问题。



Answer 2:

正如@cimmanon关闭此指出<table>标签将是一个非常好的开始



Answer 3:

对于主页脚的CSS,添加position:relativebottom:0 。 它总是被固定在底部。



文章来源: Footer wont stay at bottom of page due to a table