aboutsummaryrefslogtreecommitdiffstats
path: root/demos/position/default.html
blob: f94d316e3ca3d0d3d4309efe1fecc0615e682a4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>jQuery UI Position - Default functionality</title>
	<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
	<script src="../../jquery-1.9.1.js"></script>
	<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>
	body {
	    margin: 0;
	    padding: 0;
	}
	body > div[style*='display'] {
	    /* Workaround */
	    /* position: absolute; */
	}
	.blue {
	    background: blue;
	    float: left;
	    width: 100px;
	}
	.red {
	    background: red;
	    float: left;
	    overflow-y: hidden;
	}
	.content {
	    width: 2000px;
	    height: 400px;
	    border: 2px solid white;
	}
	#uiPosition {
	    width: 100px;
	    height: 100px;
	    background: #ccc;
	}

	</style>
	<script>
	$(function() {
		$( "#redBlock" ).css({
		    width: $( window ).width() - $( "#blueBlock" ).width()
		});
		$( ".block" ).css({
		    height: $( window ).height()
		});

		$( "button" ).on('click', function (e) {
		    $( "#uiPosition" )
		        .position({
		            my: "left top",
		            at: "left bottom",
		            of: e.target,
		            within: $( "#redBlock" ),
		            collision: "flip"
		        });
		});
	});
	</script>
</head>
<body>

	<div class="block blue" id="blueBlock"></div>
	<div class="block red" id="redBlock">
	    <div class="content">
	        <button>Position</button> 
	    </div>     
	</div>

	<div id="uiPosition"></div>

</body>
</html>