【发布时间】:2012-02-27 04:21:12
【问题描述】:
我在几张幻灯片上使用了 jQuery Cycle,下面有内容。 jQuery Cycle 将父级设置为相对,子级幻灯片设置为绝对,因此应该覆盖它下面的内容。通常,我会给父容器一个高度来解决我的问题。
由于布局是响应式的,因此高度可以改变。有没有一个简单的解决方案?
编辑:
这就是最终为我做的事情:
$(window).load(function(){
var rotate_height = $('#rotate div img').height();
$('#rotate').css('height', rotate_height);
$(window).resize(function() {
if($(window).width() >= 960){
rotate_height = 290;
$('#rotate').css('height', rotate_height);
$('#rotate').cycle('next');
} else if ($(window).width() >= 768 && $(window).width() <= 959) {
rotate_height = 230;
$('#rotate').css('height', rotate_height);
$('#rotate').cycle('next');
} else if ($(window).width() >= 480 && $(window).width() <= 767) {
rotate_height = 210;
$('#rotate').css('height', rotate_height);
$('#rotate').cycle('next');
} else if ($(window).width() <= 479) {
rotate_height = 150;
$('#rotate').css('height', rotate_height);
$('#rotate').cycle('next');
}
});
$('#rotate').cycle({
fx: 'fade',
fit: 1,
containerResize: 0,
slideResize: 0,
height: rotate_height
});
});
cycle('next') 在访问者调整其显示器大小后强制幻灯片到下一张。不理想,但图像不会按比例放大,只有在幻灯片更改后。
【问题讨论】:
-
一些示例代码会有所帮助。
-
很高兴概念上的“轻推”足以引导您找到解决方案!
标签: javascript jquery html css cycle