I have an image that I want to resize after page load to fit its parent (maybe using little animation) and then blur. Any tips?
Thanks!
L
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");
The only requirement is that you leave the parent element with position: relative
.