将页脚粘贴到页面底部的方法

发布于 2024-08-23 16:14:55 字数 5165 浏览 9 评论 0原文

我按照 如何让页脚停留在网页的底部? 在 stackoverflow 上发布...

但是我无法使其在 ASP.NET Web 应用程序中也能工作...我正在使用所有页面的母版页...

如何使页脚粘在页面底部?

参考:

<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" cellpadding="0" cellspacing="0" class="bgpatt">
<tr style="height:25px;">
<td style="width:40%">

</td>
<td  style="width:30%">

</td>
<td style="width:30%;" valign="top">

  <div id="headermenu" style="width:300px;"><ul style="width:300px;">
            <li><a title="Home" href="#" class="headerhome">Home</a></li>
            <li><a title="About Us" href="#" class="aboutus">About Us</a></li>
            <li><a title="Contact Us" href="#" class="contactus">Contact Us</a></li>
            <li><a title="Feedback" href="#" class="feedback">Feedback</a></li>
            <li><a title="Logout" href="#" class="logout">Logout</a></li>     
            </ul></div>
    </td>
</tr>
<tr style="height:25px;">
<td colspan="3">

</td>
</tr>
<tr style="height:25px;">
<td colspan="3">

</td>
</tr>
</table>
 </td>
 </tr>
<tr valign="top">
<td>
<table width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <table width="100%" cellpadding="0" cellspacing="0">



        <tr style="height:5px; background-color:#404040;">
            <td colspan="3" valign="top" style="width:100%">
                </td>
        </tr>
             </table>
                </td>
        </tr>
    </table>
</td>
</tr>
<tr>
<td>
 <table width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td style="width:45%;">

    </td>
    <td style="width:45%;">
   <div id="header" style="width:300px;"><ul id="mainMenu" runat="server">
                <li id="mainHome" runat="server"><a href="#" title="Home" class="home"><span></span>Home</a></li>
                <li id="mainManage" runat="server"><a href="Users.aspx" title="Manage" class="manage"><span></span>Manage</a></li>
                <li id="mainEnquiry" runat="server"><a href="account.aspx" title="Enquiry" class="enquiry"><span></span>Enquiry</a></li>
                <li id="mainReport" runat="server"><a href="EnquiryReport.aspx" title="Report" class="report"><span></span>Report</a></li>  

             </ul>       

</div>


    </td>
    <td style="width:10%;">

    </td>
    </tr>
    </table>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td style="width:1px;"><div style="width:1px; height:450px;"></div></td>
<td style="width:95%">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

    </asp:ContentPlaceHolder>
</td>
<td style="width:5%">
<asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<div class="wrapper"></div>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="100%" style="height:25px;">
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
 <table border="0" cellpadding="0" cellspacing="0" width="100%" style="height:35px; top:10px;" class="footer">

                                        <tr>

                                        <td style="width:100%;" align="center">


                                            <a href="#" class="footer">Home </a>|

                                            <a href="#" class="footer">About us </a>|

                                            <a href="#" class="footer">Contact us </a>|

                                            <a href="#" class="footer">Feedback </a>

                                            </td> 

                                              </tr>


                                            <tr>
                                            <td style="width:100%;" align="center" class="footer_text">
                                             Copy Rights Xavytechnologies

                                            </td>      

                                            </tr>


                                     </table>
</td>
</tr>
</table>

I followed the How do you get the footer to stay at the bottom of a Web page? post on stackoverflow...

But i couldn't make it too work in an asp.net web application.... I am using a master page for all pages...

How can i make footer stick to the bottom of the page?

For ref:

<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" cellpadding="0" cellspacing="0" class="bgpatt">
<tr style="height:25px;">
<td style="width:40%">

</td>
<td  style="width:30%">

</td>
<td style="width:30%;" valign="top">

  <div id="headermenu" style="width:300px;"><ul style="width:300px;">
            <li><a title="Home" href="#" class="headerhome">Home</a></li>
            <li><a title="About Us" href="#" class="aboutus">About Us</a></li>
            <li><a title="Contact Us" href="#" class="contactus">Contact Us</a></li>
            <li><a title="Feedback" href="#" class="feedback">Feedback</a></li>
            <li><a title="Logout" href="#" class="logout">Logout</a></li>     
            </ul></div>
    </td>
</tr>
<tr style="height:25px;">
<td colspan="3">

</td>
</tr>
<tr style="height:25px;">
<td colspan="3">

</td>
</tr>
</table>
 </td>
 </tr>
<tr valign="top">
<td>
<table width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <table width="100%" cellpadding="0" cellspacing="0">



        <tr style="height:5px; background-color:#404040;">
            <td colspan="3" valign="top" style="width:100%">
                </td>
        </tr>
             </table>
                </td>
        </tr>
    </table>
</td>
</tr>
<tr>
<td>
 <table width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td style="width:45%;">

    </td>
    <td style="width:45%;">
   <div id="header" style="width:300px;"><ul id="mainMenu" runat="server">
                <li id="mainHome" runat="server"><a href="#" title="Home" class="home"><span></span>Home</a></li>
                <li id="mainManage" runat="server"><a href="Users.aspx" title="Manage" class="manage"><span></span>Manage</a></li>
                <li id="mainEnquiry" runat="server"><a href="account.aspx" title="Enquiry" class="enquiry"><span></span>Enquiry</a></li>
                <li id="mainReport" runat="server"><a href="EnquiryReport.aspx" title="Report" class="report"><span></span>Report</a></li>  

             </ul>       

</div>


    </td>
    <td style="width:10%;">

    </td>
    </tr>
    </table>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td style="width:1px;"><div style="width:1px; height:450px;"></div></td>
<td style="width:95%">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

    </asp:ContentPlaceHolder>
</td>
<td style="width:5%">
<asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<div class="wrapper"></div>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="100%" style="height:25px;">
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
 <table border="0" cellpadding="0" cellspacing="0" width="100%" style="height:35px; top:10px;" class="footer">

                                        <tr>

                                        <td style="width:100%;" align="center">


                                            <a href="#" class="footer">Home </a>|

                                            <a href="#" class="footer">About us </a>|

                                            <a href="#" class="footer">Contact us </a>|

                                            <a href="#" class="footer">Feedback </a>

                                            </td> 

                                              </tr>


                                            <tr>
                                            <td style="width:100%;" align="center" class="footer_text">
                                             Copy Rights Xavytechnologies

                                            </td>      

                                            </tr>


                                     </table>
</td>
</tr>
</table>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

能否归途做我良人 2024-08-30 16:14:56

div

<div id="Footer"> content </div>

我建议在你的CSS中使用像这样的

#Footer
{
    position: absolute;
    bottom: 0px;
    height: 3px;
    background-color: #666;
    color: #eee;
}

,或者你可以使用AjaxControlToolkit库


我也强烈建议你将布局从Table更改为div

I suggest to use a div like

<div id="Footer"> content </div>

then in your css put this

#Footer
{
    position: absolute;
    bottom: 0px;
    height: 3px;
    background-color: #666;
    color: #eee;
}

or you can use AjaxControlToolkit library


I Also strongly recommand you change your layout from Table to div

半世晨晓 2024-08-30 16:14:56

我还推荐使用浮动的 div 结构。

标记

<div class="bodyWrap">
  <div class="header">
    <!-- Insert content here -->
  </div>
  <div class="content">
    <!-- Insert content here -->
  </div>
  <div class="footer">
    <!-- Insert content here -->
  </div>
  <div style="clear:both"></div>
</div>

CSS:

.bodyWrap
{
 width: 500px;
}
.header, .content, .footer
{
 width: 100%;
 float:left;
}

I'm would also recommend a div structure using floating.

Markup:

<div class="bodyWrap">
  <div class="header">
    <!-- Insert content here -->
  </div>
  <div class="content">
    <!-- Insert content here -->
  </div>
  <div class="footer">
    <!-- Insert content here -->
  </div>
  <div style="clear:both"></div>
</div>

Css:

.bodyWrap
{
 width: 500px;
}
.header, .content, .footer
{
 width: 100%;
 float:left;
}
尤怨 2024-08-30 16:14:56

我更喜欢下面的。它只适用于 id,不适用于类。

<div id="Footer"> content </div>    
#Footer {
                    position: fixed;
                    bottom: 0px;
        }

I liked below better. It only works with an id and not with a class.

<div id="Footer"> content </div>    
#Footer {
                    position: fixed;
                    bottom: 0px;
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文