Scattered Polaroids Gallery

A flat-style Polaroid gallery where the items are scattered randomly in a container. When a specific item is selected, it will move to the middle while the other Polaroids will make space for it by moving to the sides. Optionally, an item can have a backface which will be shown by flipping the Polaroid when clicking on the current navigation dot again.

From our sponsor: Looking for an intuitive whiteboard style project management tool? Give Shortcut a try for free.

Today we’d like to share a little gallery experiment with you. We wanted to revisit the classic look of scattered Polaroids and bring it to a next, flat level with some nice effects. The resulting gallery shows some Polaroid images with a title, randomly rotated and spread in a container. When navigating the images, the current one will be moved to the center and the resting Polaroids will move to the sides. Optionally, we’ll have a backside for each Polaroid which can be viewed by clicking the current dot of the navigation again. The indication for an existing backside will be a rotated arrow on the dot. Once the dot is clicked again, the dot itself will flip and so will the Polaroid, revealing the description on the back.

We use the following structure for the gallery:

<section id="photostack-1" class="photostack photostack-start">

		<!-- default Polaroid without backside -->
			<a href="" class="photostack-img">
				<img src="img/1.jpg" alt="img01"/>
				<h2 class="photostack-title">Serenity Beach</h2>

		<!-- Polaroid with backside -->
			<a href="" class="photostack-img">
				<img src="img/2.jpg" alt="img02"/>
				<h2 class="photostack-title">Happy Days</h2>
				<!-- optional backside -->
				<div class="photostack-back">
					<p>Fish don't fry in the kitchen and beans don't burn on the grill. Took a whole lotta tryin' just to get up that hill. Baby if you've ever wondered - wondered whatever became of me. </p>

		<!-- Example for different shuffle iteration count -->
		<figure data-shuffle-iteration="3">
			<!-- ... -->

		<!-- Example for a "dummy" Polaroid -->
		<figure data-dummy>
			<a href="#" class="photostack-img"><img src="img/7.jpg" alt="img07"/></a>
				<h2 class="photostack-title">Lovely Green</h2>
		<!-- ... -->

The “photostack-start” class can be used to show an initial overlay on the gallery container. Once the gallery is clicked, the items will make their first move and the first item will be shown in the middle.

The div with the class “photostack-back” can be used to insert some more info for the backside of the Polaroid.

The shuffle iteration count (the amount of times we want all Polaroids to move around before the next item becomes current) can be controlled with the data-attribute data-shuffle-iteration.

The can also contain “dummy” items which will be shown in the container but which will not be part of the viewable gallery. This can be useful in cases where only a subset of a certain image collection should be shown. Imagine an article about your travels where in each section you describe a specific location. You’d set the irrelevant items as dummies and only the Polaroids that are specific to that location would be viewable in detail. In the next section you’d set the others to dummies.

Note that the main wrapping div (immediate child of the section) is set to a width and height of 100%, which means that the items will be scattered across the whole container. If we would like to compact the space of spreading, we could also set the dimension of that div to a smaller one.

Take a look at some screenshots of the gallery:

Optionally, the initial state of the gallery can have an overlay
Optionally, the initial state of the gallery can have an overlay

The current image moves to the middle and the resting items will make way and move to the sides
The current image moves to the middle and the resting items will make way and move to the sides
If there is a backside, we can flip the Polaroid by clicking on the navigation dot for a second time
If there is a backside, we can flip the Polaroid by clicking on the navigation dot for a second time

I hope you like this gallery idea and find it inspirational ๐Ÿ™‚

Tagged with:

Mary Lou

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.

Stay up to date with the latest web design and development news and relevant updates from Codrops.

Feedback 90

Comments are closed.
  1. Why is there only 6 Polaroids in the Navigation, also when i have more then 6 figures in the code!?

  2. Hi, Thanks for this great code! ๐Ÿ™‚

    I was wondering.. did it use to work on chrome? I when i flip a polaroid in demo 2 or 3 it doesn’t show. Tested in other browser and they seem to work. Anyone has an idea why it doesn’t work?

    • Hi Aron, thanks for your feedback! We are looking into it; Chrome Version 37.0.2062.94 on Mac does not seem to handle the backface-visibility well here. I’ll post an update once we find out how to fix it. Thanks again and cheers, ML

    • I have found the solution. It appears, that the new version of chrome sets the z-indexes differently of transformed elements (probably to 0 or lower). I can’t confirm, but the solution is rather simple, just set the z-index of the photostack back to 1.

      .csstransformspreserve3d figure.photostack-flip .photostack-back { z-index: 1; }

      That’s it ๐Ÿ™‚

  3. Hi

    This code has stopped working in Chrome (mac) since it recently updated to version 37, any ideas how to fix the issue?

  4. Hi. I love this idea and would like to use it on my website/blog! Is there any way to import this into WordPress to use instead of their gallery?

  5. Hi Is there anyway to make this responsive I am testing it locally with webmatrix but when I open it with the iphone the images just show backwards text instead of the image

  6. This gallery looks cool ๐Ÿ™‚
    I have 16 images and it shows only 6 pictures.
    Is there any way to show all 16 pictures??

  7. I’m trying to put this in autoplay mode.

    Using this I can make them move, but…
    setInterval( function(idx) { self._shuffle(); }, 4000);

    But I can only make shuffle the ones that aren’t active.

    Can anyone help me?

  8. Hi Mary Lou,
    Many thanks for this great article and all the other ones, as I feel you provide us with great ideas for a better web!

    For this particular article, I am trying to implement it, but am struggling with contents on the back of the images, as content is sometimes longer than the container. Unfortunately setting overflow:auto on the back container does not solve the problem, as somehow the scroll bar shows, but cannot be accessed. This seems to be also linked to Arsh Shah Dilbagi (Robo)’s question from back in March, where he said he can’t select the text on the back.

    An example, using Ramosquis’ implementation: look at the second polaroid on this page, the overflow is pretty ugly as content is too long, so I tried to add overflow:auto to .photostack-back (in Chrome DevTools only).

    I have tested this in most browsers, and it only works in IE (that’s a first!). Would you be able to advise how this could be resolved? I have tried finding a solution or workaround, without success.

    Many thanks in advance for your (or anyone else’s) input,
    Wishing you all the best,

    • Update since yesterday: I have applied a Firefox update, and it seems this now works in Firefox as expected (Firefox 33.1 on Windows 8.1). The .photostack-back also responds to :hover css as expected.

      It still does not want to play nice in Chrome (I tested Chome Beta 39.0.2171 and Canary 41.0.2218).

  9. Hello,

    Can this code be used in Adobe Muse? or only in Adobe Dreamweaver? and if so, how would I go about inserting it? I’ve been searching the internet for tutorials and articles. I’m a novice and new [self-taught] to web design. Any help you can provide is welcome.

  10. Thanks Mary Lou – always look forward to learning all kinds of interesting stuff on your site. Recently integrated this into a wordpress site on their homepage link below –

    James Food Stories featuring the polaroids gallery

  11. Thanks Mary for all your awesome works,
    Can i include it in html theme on envato marketplaces ?

  12. Great ! Easy, free and fun ! thank you very much !

    Commercial com and jounralism student.