仅当内容高度适合屏幕高度时,如何在固定位置设置某些内容?

时间:2021-05-11 20:13:50

标签: html css

让我解释一下。

我有一个页脚,我想放在屏幕底部。但是,当页面内容比窗口短时(没有滚动条时),页脚在页面中太高,不在屏幕底部。

1 个答案:

答案 0 :(得分:0)

你可以有一个 <footer>id="footer" 然后在 CSS 中:

#footer {
  clear: both;
  padding: 0;
  text-align: center;
  vertical-align: middle;
  line-height: normal;
  margin: 0;
  position: fixed;
  bottom: 0px;
  width: 100%; }