0

我有这个脚本可以在悬停时放大图像缩略图。

问题是某些图像的高度不同,因此脚本有时会将它们拉伸得不成比例。大多数图像是 100x100,但有时它们是 100x140,等等。

有没有办法在调整大小时保留图像尺寸?

$("ul.gallery-large li").hover(function () {
$(this).find('img').addClass("hover").stop()
    .animate({
    width: '200px',
    height: '200px',
}, 200);

}, function () {
$(this).find('img').removeClass("hover").stop()
    .animate({
    width: '100px',
    height: '100px'
}, 400);
});
4

1 回答 1

1

你可以试试:

$("ul.gallery-large li").hover(
    function () {
        $(this).find('img').addClass("hover")
            .animate({width: '200px'}, 200);
    }, function () {
        $(this).find('img').removeClass("hover")
            .animate({width: '100px'}, 400);
    }
);

和 CSS:

ul.gallery-large li img{height:auto}

它在这里工作:http: //jsfiddle.net/dxFq6/1/

于 2013-05-17T10:54:48.153 回答