Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

javascript breaking css

I am using the following to hold a menu in place vertically but not horizontally:

<script type='text/javascript'>
$(window).scroll(function(){
    var $win = $(window);
    $('#widget_sp_image-53').css('left', 0 -$win.scrollLeft());
	$('#nav_menu-6').css('left', 0 -$win.scrollLeft());
	$('#nav_menu-5').css('left', 0 -$win.scrollLeft());
});
</script>

Open in new window


It works purfect, unless I maximize my screen and scroll down  then the three divs land 100% justified left on the edge of my screen.

I'm using this example http://jsfiddle.net/Q4dWz/  and it breaks when I use it.
ASKER CERTIFIED SOLUTION
Avatar of Gregg
Gregg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It would be interesting to know which browser does this behavior. In the jsfiddle the first box lands as you change the css values to 0 top 0 and the second box left 0 on maximizing. This is because of the css values you changed to 0 instead of 20 in the jsfiddle example.

This is in Firefox 6. Which browser do you use? Do you use the example in another context, then post the context.