How to Recreate the Banksy Artwork Shredder Using CSS Grid

CodePen included

Image for post
Image for post
Featuring a shredding of “After the Rain” by Anne Blenker. (Sorry Anne)

On Friday, Banksy pranked the world again by shredding “Girl With Balloon” immediately after it fetched $1.4 million in auction. While everyone debates if the artwork has gone up or down in value because of this, I thought it would be fun to recreate the effect in CodePen.IO using CSS Grid. You can check out the outcome of my one hour freestyle session on CodePen and continue reading for a quick overview on my approach.

I wasn’t shy to create a bunch of elements on this rough solution so I piled on a series of divs mostly positioned absolute and then centered the parent element #piece in the middle of the page.

Directly within #piece are two divs: #window and #frame. #frame is simply a 100% x 100% artwork frame image we’ll position on top of everything. The #window is positioned below and is also centered within the #piece. This #window holds our #painting div which includes both the #original and #shredded image. The real magic occurs within #shredded via a series of .shred divs which we’ll use a combination of background-image and CSS grid to create shredded versions of our artwork image. Each .shred positions the background slightly to the left.

My hacky solution then slides the entire #painting down using translateY while also resizing the #original artwork’s height to 0. Since the #original div is positioned on top of #shredded and #shredded is positioned to the bottom, subtracting its height reveals the shredded image below. You can very easily accomplish these animations directly in CSS. However, I decided to throw in Anime.JS so I had a bit more control on stopping and resetting the animation since I knew I was going to add the ability to change the image. Here’s how Anime.JS makes easy work of the animations:

And that’s about it. You can dig into the rest of the CodePen to see how I wired up the ability to change the image using Vue and Blue Imp’s excellent Javascript Load Image library.

This was a one hour hack so I’m sure readers will have a much more elegant solution in mind. Did someone say linear gradients? I would love to hear how you would do it and what sort of enhancements you might make. Happy shredding!

Written by

I develop websites for rock 'n' roll bands and get paid in sex and drugs. Previously Silva Artist Management, SoundCloud, and Songkick. Currently: Available

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store