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

推荐订阅源

W
WeLiveSecurity
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
U
Unit 42
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
H
Help Net Security
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
博客园 - 聂微东
S
Securelist
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
Cisco Talos Blog
Cisco Talos Blog

博客园 - 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 - 博客园 21个精彩的Jquery效果插件 编写跨浏览器兼容的 CSS 代码的金科玉律
转载“精简版”滚动到顶部和底部的jQuery效果
CB · 2010-10-19 · via 博客园 - CB

原文链接地址:“精简版”滚动到顶部和底部的jQuery效果

滚动到顶部和底部的jQuery效果也是一个在blog中很常见的jQuery效果。
之前一直用的是西门《缓冲版”返回顶部”》,当然现在还在继续用,觉得蛮好的,昨天看了一些jQuery的资料,浏览了一些国外jQuery代码网站,于是自己修改了一个”精简版”滚动到顶部和底部的jQuery(折腾玩玩..)。

代码

$(function() {
                
var $elem = $('#content');//此页面元素里滚动
 
                $(
'#nav_up').fadeIn('slow');
                $(
'#nav_down').fadeIn('slow');//显示按钮
 
                $(
'#nav_down').click(
                    
function (e) {
                        $(
'html, body').animate({scrollTop: $elem.height()}, 800);//按下""按钮,将页面滚动到页面底部(所示高度)
                    }
                );
                $(
'#nav_up').click(
                    
function (e) {
                        $(
'html, body').animate({scrollTop: '0px'}, 800);//按下"向上"按钮,将页面滚动到页面顶部
                    }
                );
            });

代码

.nav_up{
    padding
:7px;
    background-color
:white;
    border
:1px solid #CCC;
    position
:fixed;
    background
:transparent url(../images/arrow_up.png) no-repeat top left;
    background-position
:50% 50%;
    width
:8px;
    height
:20px;
    bottom
:10px;
    opacity
:0.7;
    left
:4px;
    white-space
:nowrap;
    cursor
: pointer;
    -moz-border-radius
: 3px 3px 3px 3px;
    -webkit-border-top-left-radius
:3px;
    -webkit-border-top-right-radius
:3px;
    -khtml-border-top-left-radius
:3px;
    -khtml-border-top-right-radius
:3px;
    filter
:progid:DXImageTransform.Microsoft.Alpha(opacity=70);
}
.nav_down
{
    padding
:7px;
    background-color
:white;
    border
:1px solid #CCC;
    position
:fixed;
    background
:transparent url(../images/arrow_down.png) no-repeat top left;
    background-position
:50% 50%;
    width
:8px;
    height
:20px;
    bottom
:10px;
    opacity
:0.7;
    left
:25px;
    white-space
:nowrap;
    cursor
: pointer;
    -moz-border-radius
: 3px 3px 3px 3px;
    -webkit-border-top-left-radius
:3px;
    -webkit-border-top-right-radius
:3px;
    -khtml-border-top-left-radius
:3px;
    -khtml-border-top-right-radius
:3px;
    filter
:progid:DXImageTransform.Microsoft.Alpha(opacity=70);
}

最后再在footer.php里面加上:

<div style=”display:none;” id=”nav_up”></div>

<div style=”display:none;” id=”nav_down”></div>

加在</body>之前。

好了,就这样。效果如本站左下角: