使HTML页面页脚以最小高度停留在页面底部但不与页面重叠的CSS

编程入门 行业动态 更新时间:2024-10-25 22:33:44
本文介绍了使HTML页面页脚以最小高度停留在页面底部但不与页面重叠的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下页面(死链接:www.workingstorage/Sample.htm),其中有一个页脚,我无法坐在该页面的底部.

I had the following page (deadlink: www.workingstorage/Sample.htm ) that has a footer that 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.

推荐答案

一种简单的方法是制作页面的正文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.

为页脚设置负的页边距顶部

Give the footer a negative margin-top:

footer { clear: both; position: relative; height: 200px; margin-top: -200px; }

更多推荐

使HTML页面页脚以最小高度停留在页面底部但不与页面重叠的CSS

本文发布于:2023-10-08 01:58:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471186.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页面   停留在   不与   最小   高度

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!