我会更详细地解释我的意思: 有一种方法可以通过用光标拖动或用手指触摸整个屏幕来移动它。然后,您可以捕捉到最靠近您所在位置的div。 div还可以根据分辨率和更改屏幕大小进行调整。 以下是主要示例:http://making.gene.com/1/start/
我对如何实现这一点感兴趣,并且我已经对这个主题进行了研究。 有许多jquery插件可以让你捕捉到div,或者在屏幕上移动一个对象,但没有达到我正在寻找的程度。
这是我的第一篇文章,所以请告诉我是否有我可以添加的内容可以帮助您。
这是一个捕捉div的例子,我能找到的最多。
<script src="src/jquery.scrollsnap.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(document).scrollsnap({
snaps: '.snap',
proximity: 50
});
});
</script>
这使您可以在靠近它时滚动到div,同时还可以更改它捕捉时的接近程度。
答案 0 :(得分:1)
试试这个http://guidobouman.github.io/jquery-panelsnap/
此插件会捕捉
部分<!doctype html>
<html>
<head>
<script src="/path/to/jquery.js"></script>
<script src="/path/to/jquery.panelSnap.js"></script>
<script>
jQuery(function($) {
$('body').panelSnap();
});
</script>
</head>
<body>
<section>
...
</section>
<section>
...
</section>
<section>
...
</section>
</body>
</html>
答案 1 :(得分:0)
你应该从这里开始
$(function() {
$( "#draggable" ).draggable();
});
工作演示:http://jqueryui.com/draggable/和http://www.elated.com/articles/drag-and-drop-with-jquery-your-essential-guide/