0

我有一个图像,我想在页面加载后调整其大小以适应其父级(可能使用小动画)然后模糊。有小费吗?

谢谢!

大号

4

1 回答 1

1
var img = $('.anImage'),
    offset = img.offset();

// position image absolutely in the same position to allow it to expand
img.css({
       position: "absolute",
       top: offset.top,
       left: offset.left,
       zIndex: 100
   })
   // animate expansion
   .animate({
       top: 0,
       left: 0,
       width: img.parent().width(),
       height: img.parent().height()
   }, "fast")
   // fadeout
   .fadeOut("fast");

唯一的要求是您将父元素保留为position: relative.

于 2011-07-24T13:43:08.067 回答