/* 内外边距通常让各个浏览器样式的表现位置不同 */
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,div,fieldset,legend,input,p,blockquote,th,td,hr,button,article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section {
margin:0;
padding:0;
}
body {
position:relative;
z-index:1000;
}
div {
position:absolute;
z-index:2000;
width:100px;
height:100px;
}
.drag {
background-color:blue;
top:0;
left:0;
}
.hit {
background-color:red;
top:100px;
left:200px;
}
此段代码可以使元素实现拖动效果,还能检测是否与目标元素发生碰撞。collisionjq 函数接受两个参数,第一个为拖动元素,第二个为目标元素。