Skip to content

Instantly share code, notes, and snippets.

@Arilas
Created March 26, 2013 09:49
Show Gist options
  • Save Arilas/5244227 to your computer and use it in GitHub Desktop.
Save Arilas/5244227 to your computer and use it in GitHub Desktop.
Demo
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jPosition demo</title>
<style>
.positionDiv {
border-radius: 12px;
box-shadow: 1px 1px 3px 3px rgba(229, 245, 171,0.9);
-moz-box-shadow: 1px 1px 3px 3px rgba(229, 245, 171,0.9);
position: absolute;
width: 75px;
height: 75px;
border-color: rgba(0,0,0,0,1);
background: #f8ffe8; /* Old browsers */
background: -moz-linear-gradient(top, #f8ffe8 0%, #e3f5ab 33%, #b7df2d 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8ffe8), color-stop(33%,#e3f5ab), color-stop(100%,#b7df2d)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f8ffe8 0%,#e3f5ab 33%,#b7df2d 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f8ffe8 0%,#e3f5ab 33%,#b7df2d 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f8ffe8 0%,#e3f5ab 33%,#b7df2d 100%); /* IE10+ */
background: linear-gradient(to bottom, #f8ffe8 0%,#e3f5ab 33%,#b7df2d 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f8ffe8', endColorstr='#b7df2d',GradientType=0 ); /* IE6-9 */
}
h1 {
margin-left: 25px;
}
.positionDiv2 {
border-radius: 12px;
position: absolute;
width: 75px;
height: 75px;
background: blue;
}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<!--<script src="/js/jquery-1.9.1.js"></script>-->
<script src="jposition/jposition.js"></script>
</head>
<body style="height: 100%; width: 100%; padding: 0; margin: 0; background-color: lightgray">
<div id="test" style="height: 100%">
<div id="targetElement" style="position: absolute; left: 30%; top: 120px; width: 300px; height: 300px; background-color: gray">
<div class="positionDiv" id="position1"><h1>1</h1></div>
<div class="positionDiv" id="position2"><h1>2</h1></div>
<div class="positionDiv" id="position3"><h1>3</h1></div>
<div class="positionDiv" id="position4"><h1>4</h1></div>
<div class="positionDiv" id="position5"><h1>5</h1></div>
<div class="positionDiv" id="position6"><h1>6</h1></div>
<div class="positionDiv" id="position7"><h1>7</h1></div>
<div class="positionDiv" id="position8"><h1>8</h1></div>
<div class="positionDiv" id="position9"><h1>9</h1></div>
<div class="positionDiv" id="position10"><h1>10</h1></div>
<div class="positionDiv2" id="position12"><h1>12</h1></div>
</div>
<div class="positionDiv" id="position11"><h1>11</h1></div>
<div class="positionDiv" id="position15"><h1>15</h1></div>
<div class="positionDiv" id="position16"><h1>16</h1></div>
</div>
<script>
$( "#position1" ).place({
around: {h: "left", v: "top"},
of: "#targetElement",
withOffset: {h: "after", v: "above"}
});
$( "#position2" ).place({
around: {h: "center", v: "top"},
of: "#targetElement",
withOffset: {h: "center", v: "center"}
});
$( "#position3" ).place({
around: {h: "right", v: "top"},
of: "#targetElement",
withOffset: {h: "before", v: "under"}
});
$( "#position4" ).place({
around: {h: "left", v: "top"},
of: "#targetElement",
withOffset: {h: "before", v: "under"}
});
$('#position5').place({
around: {h: "left", v: "center"},
of: "#targetElement",
withOffset: {h: "center", v: "center"}
});
$( "#position6" ).place({
around: {h: "left", v: "bottom"},
of: "#targetElement",
withOffset: {h: "after", v: "above"}
});
$('#position7').place({
around: {h: "center", v: "bottom"},
of: "#targetElement",
withOffset: {h: "center", v: "center"}
});
$('#position8').place({
around: {h: "right", v: "bottom"},
of: "#targetElement",
withOffset: {h: "before", v: "under"}
});
$('#position9').place({
around: {h: "right", v: "bottom"},
of: "#targetElement",
withOffset: {h: "after", v: "above"}
});
$('#position10').place({
around: {h: "right", v: "center"},
of: "#targetElement",
withOffset: {h: "center", v: "center"}
});
$( "#position11" ).place({
around: {h: "center", v: "center"},
of: "#targetElement",
withOffset: {h: "center", v: "center"}
});
$( "#position12" ).place({
around: {h: "right", v: "top"},
of: "#targetElement",
withOffset: {h: "after+100", v: "above"}
});
$('#position15').place({
around: {h: "right", v: "bottom"},
of: "#test",
withOffset: {h: "before", v: "above"}
});
$( document ).mousemove(function( event ) {
$( "#position16" ).place({
of: event,
withOffset: {h: "before", v: "above"}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment