本帖最后由 匿名 于 2014-10-27 11:20 编辑
- <div class="slide_pos">
- <div class="fix_parent">
- </div>
- <div class="fix_div">
- <p>
- <a class="links1" target="_blank">美容</a>
- </p>
- <p>
- <a href="#block2" class="links2">减肥</a>
- </p>
- <p>
- <a href="#block2" class="links2">娱乐</a>
- </p>
- <p>
- <a href="#top" class="links3">回顶部</a>
- </p>
- </div>
- </div>
- </div>
复制代码 css代码:- .side {width: 62px; height: 2580px; position:absolute; top:380px; left:50%; margin-left:500px;_display:none;}
- .fix_parent{ width:100%; float:left; height:0px; overflow:hidden;}
- .fix_div{float:left; overflow:hidden; width:62px; height:380px; background-position:-400px 0px; }
- .fix_div p{ float:left; width:62px;}
- .fix_div a{ display:block;}
- .fix_div .links1{ width:62px; height:32px; margin-top:10px; text-indent:-9999px; }
- .fix_div .links2{width:62px; height:32px; line-height:32px; text-indent:21px; color:#252525;}
- .fix_div .links3{ width:62px; height:45px; margin-top:10px; text-indent:-9999px; }
复制代码 js代码如下- $(function () { if ($(".fix_div").length > 0) { var top = $(".fix_parent").offset().top; var left = $(".fix_parent").offset().left; var ie = ietester(); $(window).scroll(function () { var limit = $(".side").offset().top + $(".side").height() - $(".fix_div").height(); if ($(window).scrollTop() >= limit) { $(".fix_div").css({ position: "static", top: limit, left: left }) } else { if (top <= $(window).scrollTop()) { if (ie <= 6) { $(".fix_div").css({ position: "absolute", top: ($(window).scrollTop()), left: left }) } else { $(".fix_div").css({ position: "fixed", top: "50px", left: left }) } } else { $(".fix_div").css({ position: "static", top: 0 }) } } }) } }); function ietester() { var undef, ie, v = 3, div = document.createElement('div'), all = div.getElementsByTagName('i'); while (div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', all[0]); v > 4 ? ie = v : ie = undef; return ie }
复制代码 |