[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

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.
0
rgranlund
Asked:
rgranlund
1 Solution
 
GreggCommented:
Are you trying to subtract win.scroll left from 0? which results in a negative number. Should it be 20 - $win.scrollleft as shown in jsfiddle?

0
 
mcnuteCommented:
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.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now