Jump to content

enlarge div on rollover


1internet

Recommended Posts

I have been trying to create a rollover effect that enlarges a div in the results page. Identical to the old google image results, when you rollover an image it would enlarge.

I am currently doing this through jquery animate

$('.product_result').hover(function(){
	$(this).css('position', 'relative')
	$(this).animate({ 
		'width': '220px',
		'height': '286px',
		'margin-left': '-6px',
		'margin-top': '-6px'
		}, 'fast');
	},function(){
	$(this).animate({
		'width': '200px',
		'height': '260px',
		'margin-left': '6px',
		'margin-top': '6px'
		}, 'fast');
});

The problem is with this code is that it distorts the position of all other elements I want it to do the equivalent effect of being position absolute, when the height and width are increased, as to not affect layouts.

Link to comment
Share on other sites

Try changing  $(this).css('position', 'relative') to $(this).css('position', 'absolute') and add a spacer element for the original size underneath to hold it's space.

Edited by nogray
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.