Annotation Overlay Effect with jQuery

Today we will create a simple overlay effect to display annotations in e.g. portfolio items of a web designers portfolio. We got the idea from the wonderful portfolio of where Flash is used to create the effect. We will use jQuery. The Website Templates that we will be using for the […]

View demoDownload source

Today we will create a simple overlay effect to display annotations in e.g. portfolio items of a web designers portfolio. We got the idea from the wonderful portfolio of where Flash is used to create the effect. We will use jQuery.

The Website Templates that we will be using for the annotated screenshots were found via the great post 60 High Quality Free Web Templates and Layouts

So, let’s start with the markup!

The Markup

The HTML is pretty simple: we have a main “portfolio” wrapper where we add the “portfolio_item” elements. Each of the elements has an “image_wrap” with the screenshot of the website, and a “zoom_overlay” with an image of the website notes inside:

<div class="portfolio">
	<div class="portfolio_item">
		<div class="image_wrap">
			<img src="images/website1.jpg" alt="Website1"/>
		<div class="zoom_overlay">
			<img src="images/website1_notes.png" alt="Website1Notes"/>

Let’s style the whole thing.


We will start by styling the big portfolio wrapper:

	margin:0 auto;

The portfolio items will have the following style:

	margin:30px auto;

The image_wrap div that contains the screenshot that we see initially, will have a table-cell display because we want to center the image inside vertically:


We will center the image horizontally by saying text-align:center. This works because an image has a default display of “inline”.

We will add a nice shadow around the image:

.image_wrap > img{
	margin:0 auto;
	-moz-box-shadow:1px 1px 7px #000;
	-webkit-box-shadow:1px 1px 7px #000;
	box-shadow:1px 1px 7px #000;

For our jQuery effect, we will want to animate the width of the image. The horizontal alignment should make the image be in the middle but the text-align property is not enough. We also need to add the auto margins to the sides to make the animation work.

The overlay div will be place absolutely, since we want it to appear on top of the image. To center it, we will apply the 50% negative margins trick:

	margin:-200px 0px 0px -200px;
	background:transparent url(../images/overlay.png) repeat top left;

The opacity is set to 0 because we will want to animate it when we show it.

The image with the notes will be hidden initially:

.zoom_overlay img{

And that’s the style! Let’s add the magic!

The JavaScript

The main idea behind the effect is to make the screenshot smaller and make an overlay with the annotations appear on top of it.
In our jQuery function we will first store the main div in a variable:

var $portfolio	= $('#portfolio');

Then we define what happens when we click on the screenshot. We will animate the image’s height and width and make the overlay appear. The overlay will animate in opacity, width, height and in margins since we want it to be centered. Remember, we were positioning it absolutely with a top and left of 50%:

	var $elem	= $(this);
	var $image	= $elem.find('img:first');
			'width'	:'400px',

	//the overlay is the next element
	var opacity	= '1';
		opacity	= '0.5'
			'width'		:'500px',
			'height'	:'500px',
			'marginTop'	:'-250px',
			'opacity'	:opacity
			//fade in the annotations

Now, we will define what happens when we click on the overlay. We will want it to disappear and make the image animate back to its initial size:

	var $elem	= $(this);
	var $image	= $elem.prev()
	//hide overlay
			'width'		:'400px',
			'height'	:'400px',
			'marginTop'	:'-200px',
			'opacity'	:'0'
			//hide overlay

	//show image

And that’s it!
To integrate this into your portfolio you need to make some transparent image with some notes that fits on the smaller sized image.

We hope you enjoyed this effect and found it useful!

View demoDownload source


Tagged with:

ML is a freelance web designer and developer with a passion for interaction design. She studied Cognitive Science and Computational Logic and has a weakness for the smell of freshly ground peppercorns.

View all contributions by


Related Articles

Receive our bi-weekly Collective or official newsletter right in your inbox.

Which newsletter would you like to receive?

CSS Reference

Learn about all important CSS properties from the basics with our extensive and easy-to-read CSS Reference.

It doesn't matter if you are a beginner or intermediate, start learning CSS now.

Feedback 28

Comments are closed.
  1. 1

    Again nice tutorial and interesting concept. In practice could it be a bit time consuming to use it?

  2. 2

    Very nice effect idea from rareview. Definitely no need for Flash.
    Great tutorial and nice coding, once again! Thanks a lot.

  3. 9

    Wow, that is a lovely script. I deff be using that, brilliant for a portfolio … thanks guys =)

  4. 10

    That’s indeed a handy little feature and I think I can already implement it in a project. Thanks a lot for the tutorial and nice timing 🙂

  5. 11

    Very cool effect!

    Actually the difficult part for me is how to create the notes. Would it be possible to have more details? And how about using text+CSS instead of an image to create the overlay?

  6. 14

    Thank you all for your great feedback!
    @Christophe, simply create a transparent image with the notes on it. Do you use/have Photoshop? Cheers, ML

  7. 15

    great !!! I love it !
    congratulations for all the work you’ve show and share us !!

    And I have to say, it’s a pleasure for the webdesign community and end user too, this is my fav tutorial website since few months

    clap clap !!

  8. 18

    This is a brilliant way to show my clients some things on a design that isn’t developed yet.
    Even better, I can use it as a portfolio thing to show or highlight specific or great areas of projects I’ve done in the past! Great concept!

  9. 20

    This tutorial is AWESOME! I actually say Rareview’s flash version months ago and have been waiting for someone (more experienced with jQuery than I) to develop this.

    You run one of the best Tutorial sites BY FAR!!!

    Thank You 🙂

Comments are closed.