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

推荐订阅源

S
Schneier on Security
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
D
DataBreaches.Net
F
Full Disclosure
腾讯CDC
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security

博客园 - 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>