我想用jquery-ui的可拖动小部件约束一个圆圈区域内的控制器。我写了一些像这样的代码:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
<style>
.draggable {
width: 80px;
height: 80px;
border: thin solid #000000;
border-radius: 40px;
position: relative;
top: 110px;
left: 110px;
background-color: #000000;
}
.containment-wrapper {
height: 300px;
width: 300px;
border: thin solid #000000;
border-radius: 150px;
}
</style>
</head>
<body>
<div class="containment-wrapper">
<div id="draggable" class="draggable"></div>
</div>
</body>
<script>
$( "#draggable" ).draggable({ containment: "parent" });
</script>
</html>
黑色圆圈可以沿着的路径实际上是一个矩形,即使包装div
的外观是一个圆圈。
如何纠正这个以符合我的目的?