帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» 回到顶部(原创)
回到顶部(原创)
浏览:580次
-
评论:0次
-
发布时间:2017-03-30
Html
Css
Js
1
2
3
4
5
6
#box { margin:0 auto; width:70%; height:3000px; background-color:rgba(247,247,247,1.00); } .top { overflow:hidden; width:100px; height:100px; left:84.8%; top:45%; position:relative; } .top_img { position:relative; bottom:0px; } h1 { text-align:center; line-height:800px }
var m_top = 300; var m_scrolltop = 0; var speed = 0.5; $(".top").stop(true, false).animate({ top: '100px' }, "100"); //改变css bottom $(document).scroll(function() { var stop = parseInt($(document).scrollTop()); $(".top").stop(true, false).animate({ top: stop + 100 + 'px' }, "100"); //改变css bottom }) var bottom = 0; var t_mover; var t_out; $(".top").mouseover(function() { clearInterval(t_out); m_over(); }); $(".top").mouseout(function() { clearInterval(t_mover); m_out(); }); function m_over() { t_mover = setInterval(function() { bottom = bottom + 100; //每次加100 是图片的高度 if (bottom > 1000) //循环400-1000的高度。眨眼睛 bottom = 400; $(".top_img").css('bottom', bottom + 'px'); //改变css bottom }, 100); //使用字符串执行方法 return bottom; } function m_out() { t_out = setInterval(function() { if (bottom < 100) { //小于等于0的时候停止 clearInterval(t_out); } else bottom = bottom - 100; //每次- 100 是图片的高度 $(".top_img").css('bottom', bottom + 'px'); }, 50); //使用字符串执行方法 return bottom; }
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
1.11.3
<!doctype html><html><head><meta charset="utf-8"><title>回到顶部(原创)-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:可爱的回到顶部插件
页面的导航的下拉滑动菜单,一个简单的不能再简单的例子,结合css3动画完成
弹窗拖拽和放大缩小
jQuery拖拽表格改变列宽
讨论这个常用代码(0)
回答他人问题或分享心得会奖励牛币
〒_〒 居然一个评论都没有……
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
580
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值