代码:jquery 吸顶 效果

时间:2016-01-13 23:42:31   收藏:0   阅读:2075

(只是个简单吸顶效果,还需完善)

 

吸顶:

<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){

    $(window).scroll( function() {
        var m =$(document).scrollTop();
        console.log(m);
        if(m>0){
            $("#aaa").addClass("abc");
        }else{
            $("#aaa").removeClass("abc");
        }
    });
});
</script>
<style type="text/css">
html,body{margin:0;padding:0;}
#aaa{width:100%;height:40px;line-height:40px;background:#3399cc;}
.abc{position:fixed;left:0;right:0;top:0;}
</style>
<div id="aaa">aaaaaaa</div>

 

 

 

 

..

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!