HTML & CSS: How to Create a Fluid Width Stack of Paper With a Single Element

Last year WebDesign.Tutsplus published a short tutorial showing how to create a stack of paper using a single html element and some css. It was nice little tutorial but the end effect wasn’t fluid. It relied on hard coded widths and so didn’t look very nice when it scaled.

I felt that making the boxes a fluid width was something I could do so I made a quick demo showing how to create fluid width stacks of paper. While I was at it I also added some subtle drop shadows for extra depth.

The secret for making this work is not using fixed width elements for the pages and instead using percentages – and then centering the elements. Since the before and after pseudo elements are absolutely positioned I set the left position to 50% and then used translateX(-50%) to push the element back over again.

How was it for you? Let me know on BlueSky or Mastodon

(Please) Link to this page

Thanks for reading. I'd really appreciate it if you'd link to this page if you mention it in your newsletter or on your blog.

Related Posts

25 Dec 2012

Learning to Accept CSS3: Creating CSS3 Windows

People are resistant to change. It’s strange since I consider myself quite forward thinking, but I still find it takes me a while to accept new things. I’ve been using CSS3 effects for quite a while now – as have...
20 Feb 2014

Fixing CSS Transitions in Google Chrome

I had a weird problem yesterday where I had applied a css transition to an element that was fading from opacity:0.1 to opacity:1 – and along the way it seemed to change in size or position.The reason for the change...
26 Sep 2018

WordPress get_post_gallery() Gutenberg Polyfill

I’m working on a new WordPress theme designed for Gutenberg, however Gutenberg isn’t finished, and there are elements that won’t work until the plugin is merged with core.One such issue, that I ran into this weekend, is that get_post_gallery() doesn’t...
03 Jun 2010

CSS Only Button – Redux

The other day, a post was published on Hongkiat showing how to make a button using CSS (Cascading Style Sheets) only. However, it was misleading as the CSS-only button also used JavaScript and an image or two. It was actually...
29 Nov 2012

CSS Highlight Colour

When I design a website I really like to add small touches that most people won’t notice. In fact there’s a blog I follow that is dedicated to these small areas of delight. One of the things I like to...
04 Dec 2012

Disable PHP Short tags

A quick tip for any WordPress devs out there (or any other devs for that matter). Don’t use PHP short tags!I’ve been bitten by this more than once in the past. Some servers allow PHP short tags (<?) and others...