我在主页上有一个旋转幻灯片,并且想根据图像的高度减去标题的高度减去箭头的高度来设置内容的高度。由于某种原因,标题或图像的高度都不会返回为 0。
见这里:http ://www.keganquimby.com/lumina/
当图像不够高时,摘录(图像旁边标题下的内容)会切入箭头,所以我想根据图像高度使用 CSS 设置它。
我的js:
jQuery(document).ready(function($){
$('.slides .slide').each(function(){
var slideHeight = $(this).height();
var headerHeight = $('.slide-content header').height();
var arrowHeight = $('.flex-direction-nav').height();
var contentHeight = slideHeight - headerHeight - arrowHeight;
});
});
新 JS(编辑以设置高度,并将其他高度调用拉到每个循环之外):
jQuery(window).load(function($){
var slideHeight = $(this).height();
var headerHeight = $('.slide-content header').height();
var arrowHeight = $('.flex-direction-nav').height();
$('.slides .slide').each(function(){
var contentHeight = slideHeight - headerHeight - arrowHeight;
$('footer.post-more').css('height', contentHeight + 'px');
});
});