" jssor滑块将始终保持宽高比,同时缩放。所以最小高度是不合理的"
大家好,我需要一个min-height函数来保持图像的一致性。
有谁知道如何修改js代码?
灵活的动态宽度很好,但在某些时候我需要一个最小高度来将图像锚定到一致的页面布局。
感谢
答案 0 :(得分:0)
//responsive code begin
//you can remove responsive code if you don't want the slider scales while window resizes
function ScaleSlider() {
var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth;
if (parentWidth) {
//for example minHeight is 300;
var minHeight = 300;
var newWidth = parentWidth;
var newHeight = jssor_slider1.$OriginalHeight() / jssor_slider1.$OriginalWidth() * newWidth;
if (newHeight < minHeight)
jssor_slider1.$ScaleHeight(minHeight);
else
jssor_slider1.$ScaleWidth(parentWidth);
}
else
window.setTimeout(ScaleSlider, 30);
}
ScaleSlider();
$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
//responsive code end