【问题标题】:html footer moves to right when table is empty?当表格为空时,html页脚向右移动?
【发布时间】:2010-10-15 20:16:34
【问题描述】:

有一个由表单标签包围的数据表。页面底部有一个固定的页脚。

当表格为空时(仅显示表格标题),整个页脚会移出屏幕的一半,向右移动。

有什么想法吗?

<form action="/cgi-bin/Lib.exe" method=POST name="dd" ID="Form1">
    <div id="yyy">          

            <table cellspacing="0" ID="Table1">

                    <thead>
                        <tr>    
                            <th>Start</th>
                            <th>End</th>
                        </tr>
                    </thead>


        <p><small><font face="Arial"><small>$DATA</small></font></small></p>   

                    <tbody>

                        <tr>                    
                            <td><input type=radio name="begin" value="$START" ID="Radio0"> $START</td>
                            <td>$END <input type=radio name="end" value="$END" ID="Radio3"></td>
                        </tr>

                        <tr>                    
                            <td><input type=radio name="begin" value="$START" ID="Radio1"> $START</td>
                            <td>$END <input type=radio name="end" value="$END" ID="Radio4"></td>
                        </tr>           


                        <tr>                    
                            <td><input type=radio name="begin" value="$START" ID="Radio2"> $START</td>
                            <td>$END <input type=radio name="end" value="$END" ID="Radio5"></td>
                        </tr>                   

                    </tbody>    
                </table>    
    </div>
                <p><small><font face="Arial"><small>$DATA</small><strong></p>

              </strong></font></small>

        </form> 









<div id="footer">
                <div id="labfooter">

                </div>
            </div>

CSS:

#footer {
    width:100%;
    height:5em;
}
html>body #footer {
    position:fixed;
    bottom:0;
    z-index:10; /* Prevent certain problems with form controls */
}

 #header,
#footer {
    color:#111;
    background:#ddd;
    text-align:center;
}  

【问题讨论】:

  • 您能否展示一些示例代码?
  • 哪个浏览器?使用 ff 3.0.7/xp 在这里工作。
  • 已修复,$DATA 标记是表格模板的标记。由于数据标记在表格之外,它把事情搞砸了。谢谢!

标签: html css layout html-table footer


【解决方案1】:

如果没有更多代码,很难进行调试。 还有您遇到问题的浏览器和操作系统?

但是,我可以说您的 html 代码无效,这可能会导致许多浏览器渲染失败。有时它可能看起来运行良好,但 DOM 可能会因不正确的代码而被抛弃。

首先尝试删除&lt;thead&gt;&lt;tbody&gt;之间的&lt;p&gt;...&lt;/p&gt;

【讨论】:

    【解决方案2】:

    validating您的代码开始。您正在混合 HTML 和 XHTML 代码,并且您的标签结构已损坏,因此需要修复一些问题。

    您可能会收到比实际错误更多的错误消息,因此只需从顶部开始并在您清楚地看到错误的情况下进行修复,然后重新验证以查看剩余的内容。

    【讨论】:

    • 为什么投反对票?如果您不发表评论解释原因,那完全没有意义。
    【解决方案3】:

    我不认为:

    html>body 
    

    在页脚语句之前。这对于您要完成的工作是不必要的,并且可能会导致问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-09
      • 2021-11-08
      • 2020-05-13
      • 2015-11-20
      • 2014-02-16
      • 2023-02-01
      相关资源
      最近更新 更多