我有一个页脚,它应该根据它的outerHeight()使用javascript函数自动显示,但它没有..调试时我得到空值..
<section class="z-index-1 pull-bottom-fixed full-width" data-pages="reveal-footer">
<section>
<div class="container">
<dv class="row"></div>
<dv class="row"></div>
</div
</section>
<section>
<div class="container">
<div class="row"></div>
<dv class="row"></div>
</div>
</section>
</section>以下是Here footer函数
Pages.prototype.initRevealFooter = function() {
var _elem = $('[data-pages="reveal-footer"]');
setHeight();
function setHeight(){
var h = _elem.outerHeight();
_elem.prev().css({
'margin-bottom':h
})
}
$(window).resize(function(){
setHeight();
})
}当我检查_elem.outerHeight()时,我得到的结果是null ...
我使用的是最新的JQuery版本( 1.11.3 ),我向下阅读了有关outerHeight()的jQuery ...
更新
在OS上的FF和Chrome上,大小调整工作正常(出现滑块,我可以滚动到底部看到页脚),但在Safari上不行。
所以Safari不喜欢这段代码
Pages.prototype.initRevealFooter = function() {
var _elem = $('[data-pages="reveal-footer"]');
setHeight();
function setHeight(){
var h = _elem.outerHeight();
_elem.prev().css({
'margin-bottom':h
})
}
$(window).resize(function(){
setHeight();
})
}发布于 2015-08-23 02:32:21
如果这是页面上仅有的代码,而不是像@charlietfl评论的那样-如果元素没有内容或样式,就没有高度。
你应该发布更多的代码。
请查看此笔以获取适用于-> http://codepen.io/anon/pen/jPjjYg的示例
CSS
[data-pages="reveal-footer"]{
height: 10px;
background-color: lime;
}JS
_g = jQuery('[data-pages="reveal-footer"]');
g.css({'border': '1px solid blue'});
var hh = g.outerHeight(); //returns 12发布于 2015-08-23 20:10:14
在Chrome,FF和Safari中测试了相同的代码后发现了这个问题...在FF和Chrome上工作得很好,但在Safari上就不行
我修改了css..。正在body标记中插入overflow: auto ...
/*[1. Layouts] */
html,
body {
height: 100%;
overflow: auto;
}这解决了问题..。现在可以显示页脚了,在html代码和js代码中都没有错误...只有CSS默认溢出!不知道为什么Safari默认设置为no,FF/Chrome默认设置为yes
https://stackoverflow.com/questions/32159085
复制相似问题