react实现拖动指定对象效果代码
代码语言:html
所属分类:拖放
代码描述:react实现拖动指定对象效果代码,绿色智能拖拽到右侧绿色的长条上,蓝色也是如此。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { background: #ddd; } * { box-sizing: border-box; } .dnd-example { display: flex; flex-wrap: wrap; width: 740px; padding: 30px; margin: 100px auto 0; background: white; font-family: sans-serif; font-size: 19px; text-align: center; } .dnd-example, .dnd-example div { border-radius: 10px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .dnd-example.dragging * { cursor: -webkit-grabbing; cursor: grabbing; } .drop-description { width: 100%; font-weight: 300; margin: 1em 0 0; } .dnd-source-objects { margin-right: 30px; } .dnd-source-object { width: 240px; line-height: 38px; border-radius: 10px; font-weight: bold; font-size: 24px; color: rgba(0, 0, 0, 0.2); cursor: -webkit-grab; cursor: grab; } .dnd-source-object:not(:last-child) { margin: 0 0 10px; } .dnd-source-object.green { background: #B0DE6B; } .dnd-source-object.blue { background: #76C9DE; } .dnd-drop-targets { background: #948F8F; flex: 1; padding: 15px; } .dnd-drop-target { position: relative; background: white; line-height: 50px; font-weight: 300; overflow: hidden; } .dnd-drop-target:not(:last-child) { margin: 0 0 10px; } .dnd-drop-target.green:before, .dnd-drop-target.blue:after { content: ""; position: absolute; left: 0; width: 20px; height: 100%; background: #B0DE6B; } .dnd-drop-target.blue:after { background: #76C9DE; } .dnd-drop-target.green.blue:after { left: 20px; } .dnd-drop-target.active.hover:after, .dnd-drop-target.active.hover:before { display: none; } .dnd-drop-target.active-green.active { box-shadow: 0 0 0 3px #948F8F, 0 0 0 4px #B0DE6B; } .dnd-drop-target.active-green.........完整代码请登录后点击上方下载按钮下载查看
网友评论0