码迷,mamicode.com
首页 > 其他好文 > 详细

随滚动条浮动的链接块层

时间:2015-01-29 19:23:51      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

<script type="text/javascript">
    function scrollImg() {
        var posX, posY;
        if (window.innerHeight) {
            posX = window.pageXOffset;
            posY = window.pageYOffset;
        }
        else if (document.documentElement && document.documentElement.scrollTop) {
            posX = document.documentElement.scrollLeft;
            posY = document.documentElement.scrollTop;
        }
        else if (document.body) {
            posX = document.body.scrollLeft;
            posY = document.body.scrollTop;
        }

        var ad = document.getElementById("ad");
        ad.style.top = (posY + 100) + "px";
        ad.style.left = (posX + 50) + "px";
        setTimeout("scrollImg()", 100);
    }
</script>
<div id="ad" style="position: absolute; background: #eeeeee; text-align: center">
    <div class="well sidebar-nav">
    <ul class="nav nav-list">
        <li class="nav-header">Hello,Chris!</li>
        <hr />
        <li class="nav-header"><span style="color:red;">Hot Links</span></li>
        <li><a href="#">DART</a></li>
        <li><a href="#">DARTboard</a></li>
        <li><a href="#">Lowes.com</a></li>
        <li><a href="#">MPT</a></li>
    </ul>
        </div>
</div>
<script type="text/javascript">
    scrollImg();
</script>

运行效果:

技术分享技术分享

随滚动条浮动的链接块层

标签:

原文地址:http://www.cnblogs.com/ethanwill/p/4260662.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!