1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Fixed Floating Elements</title>
<style>
body {
color:#616161;
font-family:"Josefin Sans",Josefin,sans-serif;
line-height:1.em;
}
#cc-sidecart {
float:left;
width:188px;
}
#cc-sidecart-wrapper {
position: relative;
}
#cc-sidecart-wrapper { /* required to avoid jumping */
left: 940px;
position: absolute;
margin-left: 10px;
width:280px;
}
#cc-sidecart {
position: absolute;
top: 0;
margin-top: 20px;
margin-bottom 20px
padding-top: 19px;
}
#cc-sidecart ol li:first-child {
border-top: 0;
}
#cc-sidecart.fixed {
position: fixed;
top: 0;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script>
$(function () {
var msie6 = $.browser == 'msie' && $.browser.version < 7;
if (!msie6) {
var top = $('#cc-sidecart').offset().top - parseFloat($('#cc-sidecart').css('margin-top').replace(/auto/, 0));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= top) {
// if so, ad the fixed class
$('#cc-sidecart').addClass('fixed');
} else {
// otherwise remove it
$('#cc-sidecart').removeClass('fixed');
}
});
}
});
</script>
</head>
<body>
</div>
<div id="sub_nav">
<div id="cc-sidecart-wrapper"><div id="cc-sidecart">
</div>
<script type="text/javascript">/* <![CDATA[ */
jimdoGen002.regModule("sidebar_shoppingcart", {"variant":"default"});
/* ]]> */
</script></div>
</div>
</body>
</html> |
Partager