mat*_*att 14 html css html5 footer
这个古老的问题.我需要<footer>在页面底部放置一个元素.但是我没有包装div.
我确实有以下结构......
<body>
<header>
<section id="content">
<footer>
</body>
Run Code Online (Sandbox Code Playgroud)
如果内容不够高,是否有一种简单的方法将页脚推到底部?
Tra*_*Coy 17
来自这个问题,并认为我会发布我遇到的情况.对我来说似乎是理想的方式.
CSS:
html {
position: relative;
min-height: 100%;
}
body {
margin: 0 0 100px; /* bottom = footer height */
}
footer {
position: absolute;
left: 0;
bottom: 0;
height: 100px;
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
HTML5:
<!DOCTYPE html>
<head>
<title></title>
</head>
<body>
<nav></nav>
<article>Lorem ipsum...</article>
<footer></footer>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
所有功劳都归功于http://mystrd.at/modern-clean-css-sticky-footer/
Mar*_*c B 10
做到了position: fixed; bottom: 0, height: xxx吗?当然,如果页面实际超过窗口底部,它会重叠任何内容.也许有些JS可以检测"短"内容并设置适当的css.