html - 如何使页脚始终位于页面底部?

标签 html css footer

我有一张 115px 的图片,我想将它放在页面的最底部。我在网上搜索如何让它一直在页面底部,得到了很多复杂的答案。我用自己的代码制作的(至少在我的浏览器中)。我意识到这可能是一种不成熟的方法,想看看它是否有任何潜在的问题。这是我的代码

<div id="footer" style="position:fixed;top:100%;margin-top:-115px;left:0%;repeat:repeat-x;background:url(http://EXAMPLE.com/images/bottom-border.png);height:115px;width:100%;">
&nbsp;
</div>

最佳答案

下面是页脚始终位于页面底部的方法。您可以替换 footer<div id="footer">...</div> , 但我更喜欢 HTML5 footer .

enter image description here

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style>
        body { height: 100%;}
        footer {background: url(http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=5); 
                position: fixed; bottom: 0; left: 0; height:115px;width:100%; }
    </style>
</head>
<body>
    <footer>

    </footer>
</body>
</html>

关于html - 如何使页脚始终位于页面底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14960467/

相关文章:

CSS固定流体(溢出:auto)-fixed layout

html - 使用具有当前状态的图像和 CSS 的导航栏

javascript - 如何在 JavaScript 函数中使用引导警报消息?

html - 将div定位在中心css

javascript - 使用 setCustomValidity() 时,针对特定于 IE 的 html5 验证有问题

html - 另一个 div 内的 Div 框没有出现

css - 不换行到下一行的固定宽度 div 内的链接

iphone - 在 TableView 单元格末尾的页脚中添加按钮

javascript - 根据用户屏幕尺寸更改元素的位置。如何为移动设备堆叠这些元素?

ios - 不要在 UITableView contentSize 中包含 tableViewFooter?