粘性页脚在 Safari 和 Chrome 上效果不佳
在这种情况下会发生什么?这是一个非常好的 .NET 网站,但是当我在 Safari 或 chrome 中检查该网站时,有时页脚无法正常工作,我必须滚动页面(移动滚动条)以使其适合正确的位置。这是一件非常奇怪的事情。
这是我正在使用的粘性页脚插件,是迄今为止我用过的最好的插件,它取自网站 http://www.drupalcoder.com/sticky-footer-plugin.html
我已经使用并尝试了其他 cssstickyfooter.com 和 ryanfait.com 以及许多其他网站,下面这个是迄今为止我见过的最好的。 但它在 Safari 和 Chrome 上效果不佳。
看看这个:
<script type="text/javascript">
$(document).ready(function() {
$("#footer").stickyFooter();
});
// sticky footer plugin
(function($) {
var footer;
$.fn.extend({
stickyFooter: function(options) {
footer = this;
positionFooter();
$(window)
.scroll(positionFooter)
.resize(positionFooter);
function positionFooter() {
var docHeight = $(document.body).height() - $("#sticky-footer-push").height();
if (docHeight < $(window).height()) {
var diff = $(window).height() - docHeight;
if (!$("#sticky-footer-push").length > 0) {
$(footer).before('<div id="sticky-footer-push"></div>');
}
$("#sticky-footer-push").height(diff);
}
}
}
});
})(jQuery);
</script>
What can be happening in this case ? It's a very nice .NET website, but when I check the website in Safari or chrome, sometimes the footer doesnt work well, and I have to scroll the page (move the scroll bar) so it fits in it's rigth place. It's a very weird thing.
This is the sticky footer plugin I'm using , the best I've used so far, it was taken from a site http://www.drupalcoder.com/sticky-footer-plugin.html
I've already used and tried the other cssstickyfooter.com and ryanfait.com and many others, this one below has been the best I've seen so far.
But it doesn't work well on Safari and Chrome.
Check this out:
<script type="text/javascript">
$(document).ready(function() {
$("#footer").stickyFooter();
});
// sticky footer plugin
(function($) {
var footer;
$.fn.extend({
stickyFooter: function(options) {
footer = this;
positionFooter();
$(window)
.scroll(positionFooter)
.resize(positionFooter);
function positionFooter() {
var docHeight = $(document.body).height() - $("#sticky-footer-push").height();
if (docHeight < $(window).height()) {
var diff = $(window).height() - docHeight;
if (!$("#sticky-footer-push").length > 0) {
$(footer).before('<div id="sticky-footer-push"></div>');
}
$("#sticky-footer-push").height(diff);
}
}
}
});
})(jQuery);
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议尝试仅使用 CSS 的解决方案链接。这适用于禁用 javascript 的浏览器。
I recommend trying a CSS only solution link. That will work on browsers with disabled javascript.
以下是我们如何完成我们的纯 CSS 解决方案
标记
CSS
Here's how we've done our CSS ONLY solution
Markup
CSS
您是否尝试过 CSS-Tricks?
标记
css
脚本
演示链接
Have you tried the one over at CSS-Tricks?
markup
css
script
DEMO LINK