刘明野

侧边栏固定浮动小工具

分享下本站的侧边小工具代码 取自inlo主题
html

<div id="scroll_box">
    <div class="widget-box-scroll">
        <section class="widget">
        <h3 class="widget-title">侧边固定</h3>
        <ul class="widget-list">
            <li>固定小工具 可放置广告</li>
        </ul>
        </section>
    </div>
</div>

css

.widget-box-scroll {
    width: 295px;
}
.follow {
    position: fixed;
    top: 0;
    margin-top: 60px;
}

js

$(function() {
    $(window).scroll(function() {
        var c = $(window).scrollTop();
        0 < $("#scroll_box").length && ($("#scroll_box").offset().top-60 < c ? $("#scroll_box .widget-box-scroll").addClass("follow") : $("#scroll_box .widget-box-scroll").removeClass("follow"))
    })
});
本文为作者刘明野发布,未经允许禁止转载!
1829
0
0
发表留言

友情链接