首页 > 编程语言 > 详细

javascript 滚动条下拉导航fixed

时间:2014-11-23 17:28:41      阅读:287      评论:0      收藏:0      [点我收藏+]
<!doctype html>

<html>
<style>
    body{
        margin:0;
        padding:0;    
    }
    #top{
        background:#000;
        width:400px;
        height:30px;
        
    }
    .a{
        position:fixed;
        top:0;
        left:0;
    }

</style>
    <body>
        <div style="height:300px;width:100%;background:#ccc;">
        </div>
        <div id="top">
        </div>
        <div style="height:1900px;">
        </div>
    
        <script>
        window.onscroll=function(){
        var t = document.documentElement.scrollTop || document.body.scrollTop;  
        var Otop =    document.getElementById(top);
            if(t > 300){
                var A = Otop.offsetHeight+Otop.offsetTop;
                Otop.style.position=fixed;
                Otop.style.left=0;
                Otop.style.top=0;
            }else{
                Otop.style.position=‘‘;
            }
        }

        
        </script>
    
    </body>
</html>

 

javascript 滚动条下拉导航fixed

原文:http://www.cnblogs.com/xinlinux/p/4116673.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!