7 days of unlimited WordPress themes, plugins & graphics - for free!* Unlimited asset downloads! Start 7-Day Free Trial
  1. Web Design
  2. CSS

Create a Flexible Folded Paper Effect With CSS3

Scroll to top
Read Time: 8 mins

In this tutorial we'll learn to create a flexible (responsive) folded paper effect using CSS3 features like background gradients and box-shadows, which can give a cool-looking background to the content area of your website.

Step 1: Setting up the <head>

Let's start out by making a very basic HTML page. We'll use HTML5 because.. why wouldn't you?!

In the head we make sure we use the HTML5 doctype, we set our title, we call in our stylesheets, we also use the viewport meta tag so that our effect will be responsive on mobile and tablet devices. Finally, there's a polyfill to get html5 elements recognized in older browsers, and there's also a fix for CSS3 gradients for IE which we'll need later in the tutorial.

Step 2: Setting up the <body>

Now, in the main section of the page we have one div container wrapping the page and another one wrapping the "paper". Inside this div we'll add a <section> tag every time we want a folded section in the paper. There are two types of these sections, so later on in the CSS we'll be able to differentiate between them using the 'odd' and 'even' nth-child selectors. This way, our HTML stays as semantic as possible with no superfluous class names.

In these sections I've added some content; titles and some placeholder text. This is a pretty normal plain page structure, but we have everything we need to create the folded paper effect by moving on to the CSS.

Step 3: Styling the Overall Page

In the CSS we're going to create the effect completely from scratch, with no images, just for fun.

These are the basic styles for the page. We declare a fixed max-width and a percentage for the actual width to make the whole "paper" element flexible. The header styles are only for the example obviously, it's up to your artistic skills to change them according to your design.

Step 4: Styling Both Fold Sections

Here we're making sure that each section stretches 100% across its parent element. We define a min-height, that way if you want to add empty fold sections like we have in the example, they won't be 0px tall. We then declare the position relative and we add a bit of padding, once again only for this design.

Note: It's very important to declare position: relative; in this section; we need it to place the shadow elements which really sell the effect.

Step 4: Adding the Gradient

This time we're only styling every even section element, so that means the second, fourth, sixth etc. We're applying a gradient to give the impression of a shadow being cast on the paper in 3D space. This gradient is one of the most essential parts of this design and it's important to choose a color that compliments the paper.

In this case the paper was #f5f4f0 and so the gray of the gradient (which fades diagonally from top-left to bottom-right) is #e9eae5 to completely transparent.

You can use a number of tools to generate your gradients for you, for example:

Step 5: Adding the Shadows

With that done, let's now add some shadows under the paper.

Now I know this may seem daunting to people who aren't used to using CSS3 transforms or pseudo-elements, but this is actually quite straight forward.

Here we're just adding the shadows for each odd numbered section. We start by pushing the extra element behind the paper with the z-index. It's here that we declare a position of absolute which is why we needed to declare the position to relative in the parent element earlier.

Basically, we're making two black boxes that take up half of the width of our fold section (width: 50%;) we're then giving them box shadows and after that rotating them by an amount of 5°. These extra elements are mostly hidden, but are placed in such a way that they give the illusion of depth, as if the paper was coming away from the page. These shadows accentuate the effect created by the gradient earlier.

Step 6: Adding the Final Shadows

We now need to repeat a similar process for our evenly numbered sections.

Exactly the same as before but for a few details. Obviously we're targeting the even numbered elements and not the odd ones, and the positioning is different so the shadow is located at the top of the box and rotated the other way, thus creating a sort of triangular shadow near the point of every "fold". Here:

Step 7: Adding a few Media-queries

You'll have noticed that we've been using percentages for widths and have been setting up an environment for a responsive design. If you take the example as it is now and resize it down it works quite well. But there are imperfections. These can be fixed with a few corrections that kick in at certain points.

So here we've just made our headings smaller (once again just for the demo) we've also had to replace the pseudo-elements ever so slightly because they were showing at small viewports. I chose 600px as the break point purely because that's when the shadows became too big in my eyes, once again this is completely open for you to change according to your design.

Browser Compatibility

As we're using CSS3 gradients, browser compatibility is limited to modern browsers and Internet Explorer 10. Our gradients do have a backup filter property to give us access to IE9, so that just discounts IE8 and earlier. IE8 actually trips up in a number of ways (our CSS3 selectors, transform rules and box-shadows, so let's just forget about IE8 completely!) Thankfully, it's a graceful degradation and the content of the page is perfectly accessible:


Don't forget that your media queries will also need to contain the only keyword, to prevent IE8 from parsing all their contents by default.


So there you have it! A flexible folded paper effect created with CSS3 gradients, box-shadows and pseudo elements. I hope you've enjoyed this tutorial and hopefully learned something useful from it. Let me know in the comments I'd love to hear your opinions.

Did you find this post useful?
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Web Design tutorials. Never miss out on learning about the next big thing.
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.