views:

82

answers:

1

I'm looking to create something like what Apple has on their online store for displaying the summary of your computer and total as seen here. I'm guessing this is JavaScript, but it'd be even cooler if it could be done in CSS.

Basically I'd like something scrolls with the page like position:fixed, but I don't want it to start moving until the user has scroll past a certain position.

I'm using jQuery, so a jQuery plugin would be perfect as well.

+2  A: 

Try something like this

var min = 10; //Set your own here
$(window).scroll(function() { 
  var scrollTop = $(window).scrollTop()
  if(scrollTop > min)
    $('.divClass').css({  top: "0" });
  else
    $('.divClass').css({ top: (min - scrollTop) + "px" });
});

CSS

.divClass
{
  position:fixed,
  left: 500px /* or whatever */
}
helios456
Nice. A little tweaking and it's perfect! I changed the first top:"0" to top:"10px" so there's a little padding between the div and the top of the page. I also didn't need the left:500px; in the CSS (but I do need the fixed).
Darryl Hein