This is a little jQuery snippet for a sticky scrolling shoppingcart like the one Apple uses at the Apple Onlinestore: http://store.apple.com/de/configure/MB950D/A?mco=MTM3NTgzMTk
jQuery:
$(document).ready(function() {
// check where the shoppingcart-div is
var offset = $('#shopping-cart').offset();
$(window).scroll(function () {
var scrollTop = $(window).scrollTop();
// check the visible top of the browser
if (offset.top<scrollTop) {
$('#shopping-cart').addClass('fixed');
} else {
$('#shopping-cart').removeClass('fixed');
}
});
});
CSS:
.fixed {
position: fixed;
top: 20px;
margin-left: 720px;
background-color: #0f0 ! important;
}