From time to time designers might want you to add images to your website. But they want to add them to the oddest places - at least you think so. There is nothing wrong with the place the pictures shall be added, but you know that with pure HTML/CSS the positioning might be very hard. This is why we created Picturetape.
With Picturetape you can tape your pictures to any DOM element in a very flexible way.
$(document).ready(function() { $('#custom-element').picturetape({ src: 'path/to/image.png' }); });
Use this sandbox to play around. Just fill in some values.
Use the options x and y to position the image using relative/percent values.
This example tapes the top-left corner of the image to the center of #custom-element:
$('#custom-element').picturetape({ src: 'path/to/image.png', x: 50, y: 50 });
Use the options offset_x and offset_y to position the image using pixel values.
With the options of this example you can tape the image to the #custom-element with a x-offset of 10 pixel and a y-offset of 15 pixel:
$('#custom-element').picturetape({ src: 'path/to/image.png', offset_x: 10, offset_y: 15 });
Combine x, y, offset_x and offset_y to unleash the power of Picturetape.
This example will tape the image to the right middle of #custom-element and offset it by (10,15) pixels afterwards.
$('#custom-element').picturetape({ src: 'path/to/image.png', x: 100, y: 50, offset_x: 10, offset_y: 15 });
Usually images are positioned using the top-left corner as anchor. With Picturetape you can change this behaviour using the anchor_x and anchor_y values. Those are specified using percentual values.
Using the values of this example the center of the image will be taped to the #custom-element. As we did not specify anything else this will be the top-left corner:
$('#custom-element').picturetape({ src: 'path/to/image.png', anchor_x: 50, anchor_y: 50 });
You can use all options in combination to position your pictures as you wish.
Specify the id of the image using the id option.
$('#custom-element').picturetape({ src: 'path/to/image.png', id: 'unique-id' });
To specify classes the image will receive add an array with class names via the classes option.
$('#custom-element').picturetape({ src: 'path/to/image.png', classes: ['class-1', 'class-2'] });
$(selector).picturetape(options);
The only required
option is the src option. But without positioning information you would not need Picturetape. So consider using them.