2012-04-15 18:25:55 +00:00
|
|
|
<!doctype html>
|
2009-07-24 18:24:13 +00:00
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2010-09-10 14:24:33 +00:00
|
|
|
<meta charset="utf-8">
|
2009-07-24 18:24:13 +00:00
|
|
|
<title>jQuery UI Position - Default functionality</title>
|
2010-09-10 14:24:33 +00:00
|
|
|
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
|
2013-02-05 13:47:59 +00:00
|
|
|
<script src="../../jquery-1.9.1.js"></script>
|
2010-09-10 14:24:33 +00:00
|
|
|
<script src="../../ui/jquery.ui.core.js"></script>
|
|
|
|
<script src="../../ui/jquery.ui.widget.js"></script>
|
|
|
|
<script src="../../ui/jquery.ui.mouse.js"></script>
|
|
|
|
<script src="../../ui/jquery.ui.draggable.js"></script>
|
|
|
|
<script src="../../ui/jquery.ui.position.js"></script>
|
|
|
|
<link rel="stylesheet" href="../demos.css">
|
|
|
|
<style>
|
2013-05-16 10:26:03 +00:00
|
|
|
body {
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
2010-03-17 19:22:05 +00:00
|
|
|
}
|
2013-05-16 10:26:03 +00:00
|
|
|
body > div[style*='display'] {
|
|
|
|
/* Workaround */
|
|
|
|
/* position: absolute; */
|
2010-03-17 19:22:05 +00:00
|
|
|
}
|
2013-05-16 10:26:03 +00:00
|
|
|
.blue {
|
|
|
|
background: blue;
|
|
|
|
float: left;
|
|
|
|
width: 100px;
|
2011-09-16 15:33:26 +00:00
|
|
|
}
|
2013-05-16 10:26:03 +00:00
|
|
|
.red {
|
|
|
|
background: red;
|
|
|
|
float: left;
|
|
|
|
overflow-y: hidden;
|
2011-09-16 15:33:26 +00:00
|
|
|
}
|
2013-05-16 10:26:03 +00:00
|
|
|
.content {
|
|
|
|
width: 2000px;
|
|
|
|
height: 400px;
|
|
|
|
border: 2px solid white;
|
2010-03-17 19:22:05 +00:00
|
|
|
}
|
2013-05-16 10:26:03 +00:00
|
|
|
#uiPosition {
|
|
|
|
width: 100px;
|
|
|
|
height: 100px;
|
|
|
|
background: #ccc;
|
|
|
|
}
|
|
|
|
|
2010-03-17 19:22:05 +00:00
|
|
|
</style>
|
2010-09-10 14:24:33 +00:00
|
|
|
<script>
|
2009-07-24 18:24:13 +00:00
|
|
|
$(function() {
|
2013-05-16 10:26:03 +00:00
|
|
|
$( "#redBlock" ).css({
|
|
|
|
width: $( window ).width() - $( "#blueBlock" ).width()
|
|
|
|
});
|
|
|
|
$( ".block" ).css({
|
|
|
|
height: $( window ).height()
|
2009-07-24 18:24:13 +00:00
|
|
|
});
|
2010-09-10 14:24:33 +00:00
|
|
|
|
2013-05-16 10:26:03 +00:00
|
|
|
$( "button" ).on('click', function (e) {
|
|
|
|
$( "#uiPosition" )
|
|
|
|
.position({
|
|
|
|
my: "left top",
|
|
|
|
at: "left bottom",
|
|
|
|
of: e.target,
|
|
|
|
within: $( "#redBlock" ),
|
|
|
|
collision: "flip"
|
|
|
|
});
|
|
|
|
});
|
2009-07-24 18:24:13 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
2013-05-16 10:26:03 +00:00
|
|
|
<div class="block blue" id="blueBlock"></div>
|
|
|
|
<div class="block red" id="redBlock">
|
|
|
|
<div class="content">
|
|
|
|
<button>Position</button>
|
|
|
|
</div>
|
2010-03-17 19:22:05 +00:00
|
|
|
</div>
|
2009-07-24 18:24:13 +00:00
|
|
|
|
2013-05-16 10:26:03 +00:00
|
|
|
<div id="uiPosition"></div>
|
|
|
|
|
2009-07-24 18:24:13 +00:00
|
|
|
</body>
|
|
|
|
</html>
|