Skip to content Skip to sidebar Skip to footer

Need To Position Div Element Outside Document Area Not Working

Possible Duplicate: Position element through css Im have a problem with css positioning jQuery(this).css({'left': (jQuery(document).css('left') - jQuery(form).width())}); Im g

Solution 1:

You won't be positioning the document absolutely, so the left style attribute won't give you anything useful. Besides, you would not get a numerical value, but a string including the unit, so it couldn't be used in the subtraction anyway.

Use the position function instead:

jQuery(this).css({"left": (jQuery(document).position().left - jQuery(form).width()) + 'px' });

Solution 2:

You don't even really need to specify the 0, you can just negate the width of the form. If you really want to use a value, but not 0, you could try screen.availLeft Mozilla's spec

jQuery(this).css({"left": (-jQuery(form).width())});

or

jQuery(this).css({"left": (window.screen.availLeft-jQuery(form).width())});

Post a Comment for "Need To Position Div Element Outside Document Area Not Working"