Created
July 24, 2012 14:52
-
-
Save samuelcotterall/3170418 to your computer and use it in GitHub Desktop.
Adam’s link idea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var circle = $("a.circle"), | |
circleOffset = $(circle).offset(), | |
parent = $(circle).parent('li,p,blockquote'), | |
parentOffset = $(parent).offset(); | |
// Find position of link | |
var relativeOffsetTop = parentOffset.top - cirlceOffset.top, | |
relativeOffsetLeft = parentOffset.left - cirlceOffset.left,; | |
// Appned a <canvas> element to the parent, and position | |
$(parent).css('position', 'relative').prepend('<canvas class="behind" style="position: absolute; top: ' + relativeOffsetTop +'; left: ' + relativeOffsetLeft + '"/>'); | |
</script> | |
<p> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure <a href="#" class="circle">dolor</a> in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | |
</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment