检查元素是否在 clientHeight 中
我想在页面底部设置一个div。
如果主要内容 div 小于客户端高度,那么它应该出现在页面底部。
如果内容div较大,则应将div设置在内容div下方。
这里有两张图片可以更好地解释我的问题:
< img src="https://i.sstatic.net/16W43.png" alt="http://www.suckmypic.net/26000/45dfbe5c.png">
有人能告诉我如何做到这一点的逻辑吗?
I want to set a div at the bottom of the page.
If the main content div is smaller then the client height, then it should appear at the bottom of the page.
If the content div is bigger, then the div should be set below the content div.
Here are two images to explain my problem better:
Can anybody tell me the logic how to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有几种方法可以做到这一点,您在谷歌中寻找
粘性页脚
类型,您会得到很多结果。尝试一下: http://css-tricks.com/snippets/css/sticky -页脚/
there are several ways to do this, your looking for a
sticky footer
type that in google and you'll get lots of results.give this a try: http://css-tricks.com/snippets/css/sticky-footer/
这很容易做到。
请参阅这两个演示页面:-
情况1:当content div小于window时-> http://jsbin.com/otulog/2
情况 2:当 content div 大于 window -> ; http://jsbin.com/otulog/3
This can be done easily.
See these two demo pages:-
Case 1: When content div is smaller then window -> http://jsbin.com/otulog/2
Case 2: When content div is larger then window -> http://jsbin.com/otulog/3