簡體   English   中英

如何在翻轉時使用jquery更改單個圖像的大小?

[英]How do I change the size of an individual image with jquery on rollover?

我在http://www.lightsandfire.com上使用CSS轉換完成了效果,但在IE中不起作用,如何在jquery中創建相同的效果? 我希望能夠將圖像翻轉並使圖像的尺寸超出文檔流。 當我用鼠標滑過圖像時,我想按比例更改圖像的大小。 如果圖像尺寸增加100%,那將是我想要的。

任何幫助,將不勝感激。

您需要使用動畫,並對寬度和高度進行動畫處理。 高度和寬度的動畫與跨瀏覽器兼容。

要在懸停時為對象設置動畫:

$('.item').hover(function() {//Hovering
    $(this).animate({
        width: '400px',
        height: '400px',
        marginLeft: '-200px',
        marginTop: '-200px'
    }, 400);//Speed of animation in ms
}, function() { //Not hovering
    $(this).animate({
        width: '200px',
        height: '200px',
        marginLeft: '-100px',
        marginTop: '-100px'
    }, 400);
});

要使其單擊,只需將鼠標懸停更改為mouseDown。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM