CSS to make HTML page footer stay at bottom of the page with a minimum height, but not overlap the page(CSS使HTML页面页脚以最小高度留在页面底部,但不与页面重叠)
问题描述
我有以下页面(死链接:http://www.workingstorage.com/Sample.htm
)有一个页脚,我无法将其放在页面底部.
I have the following page (deadlink: http://www.workingstorage.com/Sample.htm
) that has a footer which I can't make sit at the bottom of the page.
我希望页脚
- 当页面较短且屏幕未填满时,贴在窗口底部,并且
- 当内容超过一屏时(而不是重叠内容),停留在文档末尾并正常向下移动.
CSS 是继承的,让我很困惑.我似乎无法正确更改它以在内容上设置最小高度或使页脚移至底部.
The CSS is inherited and befuddles me. I can't seem to change it properly to put a minimum height on the content or make the footer go to the bottom.
推荐答案
一个简单的方法是让你的页面的body 100%
,加上一个min-height
100%
.如果您的页脚高度没有改变,这很好用.
A simple method is to make the body 100%
of your page, with a min-height
of 100%
too. This works fine if the height of your footer does not change.
给页脚一个负边距:
footer {
clear: both;
position: relative;
height: 200px;
margin-top: -200px;
}
这篇关于CSS使HTML页面页脚以最小高度留在页面底部,但不与页面重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CSS使HTML页面页脚以最小高度留在页面底部,但不与页面重叠


- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01