jQuery实现div浮动层跟随页面滚动效果


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="滚动,漂浮层,php,jquery" />
<meta content="Helloweba演示平台,演示XHTML、CSS、jquery、PHP案例和示例" />
<title>jQuery实现浮动层跟随页面滚动效果</title>
<link type="text/css" href="https://www.jb51.net/css/main.css" />
<style type="text/css">
#main{height:2000px}
.demo{width:180px; height:250px; margin:10px; border:2px solid #ccc; background:#eee; padding:10px; }
#demo1{position:relative; margin-top:-290px;}
#demo2{position:absolute; margin-top:156px; right:10px;}
.demo a{text-decoration:underline; cursor:pointer}
.demo h3{font-size:14px}
.demo p{line-height:20px}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="https://www.jb51.net/jquery.cookie.js"></script>
<script type="text/javascript" src="https://www.jb51.net/jquery.scroll-follow.js"></script>
<script type="text/javascript">
$(function(){
$("#demo1").scrollFollow({
offset: 156
});
$("#demo2").scrollFollow({
speed:1000,
//offset: 156,
//relativeTo:"bottom",
killSwitch: "switchlink",
onText: '取消滚动',
offText: '开启滚动'
});
});
</script>
</head>

<body>
<div>
<img src="https://www.jb51.net/pic.jpg" />
<h3>Demo 1</h3>
<p>滚动鼠标滚轮或者拖动浏览器的滚动条看看。</p>
</div>
<div>
<img src="https://www.jb51.net/pic1.jpg" />
<h3>Demo 2</h3>
<p>你可以通过点击下面的链接来开启和关闭浮动层的跟随滚动效果。</p>
<p><a>启动开关</a></p>
</div>
<div>
<div><h1><a href="https://www.helloweba.com" title="返回helloweba首页">helloweba</a></h1></div>
</div>


<div>
<h2><a href="https://www.helloweba.com/view-blog-85.html">jQuery实现浮动层跟随页面滚动效果</a></h2>
</div>
<div>
<p>Powered by helloweba.com 允许转载、修改和使用本站的DEMO,但请注明出处:<a href="https://www.helloweba.com"></a></p>
</div>
<p><script type="text/javascript" src="https://js.tongji.linezing.com/1870888/tongji.js"></script></p>

</body>
</html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdyxxg.html