可以使全屏图像缩放吗?

时间:2013-07-24 15:56:48

标签: javascript jquery css image fullscreen

我尝试将图像放在全屏幕上,图像也可以缩放。 我用它来缩放这个jquery插件http://www.jacklmoore.com/wheelzoom/ 并且对于完整的全屏,此处描述的所有选项 Full-screen responsive background image

在我的测试中,可以放大图像,但如果调整窗口大小,图像不会调整大小并在边框之间显示空格。

我不知道将图像放在div中是否更好,并将此div设为全屏。

1 个答案:

答案 0 :(得分:0)

如果您向我们提供小提琴,我们可以做其他事情,但一个选项似乎是在Windows调整大小时改变图像大小:

$(window).resize(function() {

    //in order to call the functions only when the resize is finished
    //http://stackoverflow.com/questions/4298612/jquery-how-to-call-resize-event-only-once-its-finished-resizing
    clearTimeout(resizeId);
    resizeId = setTimeout(doneResizing, 500);       
});

function doneResizing(){
    var windowsWidtdh = $(window).width();
    var windowsHeight = $(window).height();

    //setting your image dimensions 
    $('#yourImage').css('height', windowsHeight );
    $('#yourImage').css('width', windowsWidtdh );

}
相关问题