我有一张 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%;">
</div>
最佳答案
下面是页脚始终位于页面底部的方法。您可以替换 footer
与 <div id="footer">...</div>
, 但我更喜欢 HTML5 footer
.
<!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/