惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
罗磊的独立博客
SecWiki News
SecWiki News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
IT之家
IT之家
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Vercel News
Vercel News
G
GRAHAM CLULEY
D
DataBreaches.Net
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
T
Tenable Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
J
Java Code Geeks
博客园 - Franky
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
T
Threatpost
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
Recent Announcements
Recent Announcements
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
U
Unit 42
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
K
Kaspersky official blog
有赞技术团队
有赞技术团队
B
Blog
腾讯CDC

博客园 - CB

用HTML5 Canvas为网页添加动态波浪背景 SVG 动画实现弹性的页面元素效果 Trianglify – 五彩缤纷的 SVG 背景图案 『转』Photoshop中改进ios设计流程的30个诀窍 【转】6 个强大的 HTML5 应用在线开发工具 【转】2012年度最新免费web开发设计资源荟萃 【转】inline-blcok 前世今生 【转】60款很酷的 jQuery 幻灯片演示和下载 【转载】用CSS3做的动画按钮 【转载】时尚的CSS3进度条 【转】[jQuery插件]图片居中裁切效果 漂亮的表格 6款强大的jQuery插件 创建和加强网站布局 RMB符号的几种显示方式。 2010年最佳jQuery插件 网站开发人员应该知道的62件事 - CB - 博客园 转载“精简版”滚动到顶部和底部的jQuery效果 21个精彩的Jquery效果插件 编写跨浏览器兼容的 CSS 代码的金科玉律
[转载] 模仿淘宝列表页面的工具栏随屏幕滚动效果
CB · 2011-01-10 · via 博客园 - CB

转自  http://bbs.blueidea.com/thread-2997920-1-1.html

大家请看淘宝搜索商品,列表页面的效果
 

工具栏原先在默认位置,然后当滚动条往下滚动,滚动条的高度>=工具栏高度的时候,工具栏就浮动然后跟随滚动条
反之,等滚动条往上滚动,滚动条的高度<=工具栏高度的时候,浮动的工具栏就消失

漂浮滚动效果无闪烁,兼容IE 6 7 8 FF等浏览器

代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>仿淘宝 工具条</title>
<style type="text/css">
html,body
{
    margin
:0px;
    height
:100%;
    overflow
:hidden;
}
#autoscroll
{    
    height
:100%;
    overflow
:auto;
    width
:100%;
    text-align
:center;
}
.box
{
    width
:960px;
    height
:100%;    
    text-align
:left;
    margin
:auto;
}
.head
{    
    width
:958px;
    height
:200px;
    border
:1px solid #eb6100;
    margin-top
:10px;
    margin-bottom
:10px;
}
.tool
{        
    width
:958px;
    border
:1px solid #eb6100;
    background
:#FFF;
}
.toolabsolute
{    
    position
:absolute;    
    z-index
:100;
    top
:1px;
}
.list
{
    width
:958px;
    height
:2400px;
    border
:1px solid #eb6100;    
    margin-top
:10px;
    margin-bottom
:10px;
}
</style>
<script src="http://www.huaian.com/jquery-1.4.2.min.js" language="javascript" type="text/javascript"></script>
</head>
<body>
        
<div id="autoscroll">
    
<div class="box">
        
<div class="head">
        网页头部
<br />
        
</div>
        
        
<div class="tool" id="mytool">
        热门城市:北京 西安 上海 深圳 广州 杭州 成都 南京 重庆 北京
<br />
        省市首字母查找:A B C F G H J L N Q S T X Y Z
        
</div>
        
        
<div class="list">
        列表部分
<br />
        
</div>        
    
</div>
</div>
<script language="javascript" type="text/javascript">
$(document).ready(
function(){
    
var mytooltop;
    
var scrolltop;
    
var toolleft;
    
var cloned=false;
    toolleft
=$(".box").get(0).offsetLeft;
    $(
"#mytool").clone(true).insertAfter("#autoscroll").css("left",toolleft+"px").addClass("toolabsolute");
    $(
".toolabsolute").hide();
    
    $(
"#autoscroll").scroll(function(){
        mytooltop
=$("#mytool").get(0).offsetTop;
        scrolltop
=document.getElementById("autoscroll").scrollTop;
        
if(scrolltop>=mytooltop && cloned==false){
            $(
".toolabsolute").show();
            cloned
=true;
        }
        
if(!(scrolltop>=mytooltop) && cloned==true){
            $(
".toolabsolute").hide();
            cloned
=false;
        }
    })
})
</script>
</body>
</html>