类似Tumblr的页脚

Chr*_*her 5 javascript

当您在Tumblr上启用无限滚动时,当您将鼠标放在仪表板的底部时,页脚就会淡入.我如何在我的网站上使用该技术?

Ahm*_*man 3

如果你使用 jQuery 库,这将非常容易。

假设您有以下 id="footer" 且具有自定义样式的页脚 div

<div id="footer" style="position:fixed;bottom:0px;left:0px;margin:0px;width:100%;opacity:0.001">
    <center>StackOverflow | About US | Privacy | Blah Blah Blah | Something </center>
</div>
Run Code Online (Sandbox Code Playgroud)

然后添加以下java脚本

<script type="text/javascript">
   $(document).ready(function() { 
    $('#footer').hover(
        function(){
            $(this).stop().fadeTo('slow',1);
        },
        function(){
            $(this).stop().fadeTo('slow',0.001);
        });

    });
</script>
Run Code Online (Sandbox Code Playgroud)

确保您已包含 jQuery 库,如果没有,只需将以下行添加到 Head 部分:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)