【发布时间】:2017-02-14 10:11:08
【问题描述】:
我创建了多个可拖动的热点,但我的问题是在同一个容器中只有一个部分;在该部分中,我不想删除可拖动元素。请检查下面的sn-p。
$(".draggable").draggable({
containment: ".container",
});
.container{
width:100%;
position:relative;
height:300px;
background:#eaeaea;
}
label{display:inline-block;}
.draggable {
position: absolute!important;
min-width: 85px;
border: none!important;
background: transparent!important;
top:0;
left:0;
z-index:1;
}
.draggable label:first-child{
background:blue;
border:1px solid green;
width:10px;
height:10px;
border-radius:50%;
float:left;
margin-top:3px;
margin-right:10px;
}
.draggable label:last-child {
overflow: hidden;
max-width: 100px;
word-wrap: break-word;
padding: 5px;
background: #9afff1;
}
.section {
position: absolute;
width: 240px;
height: 100px;
background: #dfbaba;
bottom: 0;
border: 1px solid #d5a1a1;
}
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div class="container">
<div class="draggable">
<label></label>
<label>hotspot1</label>
</div>
<div class="draggable">
<label></label>
<label>hotspot2</label>
</div>
<div class="draggable">
<label></label>
<label>hotspot3</label>
</div>
<div class="section">
</div>
</div>
在上面的 sn-p 热点可以放在红色背景部分。如何防止这种情况?请检查下图以获得更好的理解。
同样在 drop 上如何检查两个热点是否重叠?如果两个热点相互重叠,那么我想更改将改变热点方向的类。谢谢
【问题讨论】:
标签: jquery html jquery-ui drag-and-drop