原生js鼠标拖拽div左右滑动
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="js/jquery.min.js"></script> <style> body{ position: relative; margin:0; padding:0; width:100%; height: 1000px; } #box{ height: 50px; width:200px; position: absolute; left:50%; top:50%; margin-left:-200px; margin-top:-200px; background: #CDCDCD; } #small-box{ height: 50px; width:50px; position: absolute; left:0; top:0; background: #FF66CC; cursor:move ; opacity: 0.7; } </style> </head> <body> <div id="box"> <div id="small-box"></div> </div> <script> var box=$("#small-box"); var body=$('body'); var