From our sponsor: Ready to show your plugin skills? Enter the Penpot Plugins Contest (Nov 15-Dec 15) to win cash prizes!
Today we want to share an experimental 3D layout with you. It’s inspired by the famous Flipboard app where a seamlessly “normal” page flips like a page in a book when swiped. We’ve tried to re-create that effect using CSS 3D transforms and JavaScript, making a layout that is “flippable” and responsive. While the swiping makes sense for touch devices, dragging will do for normal browsers.
For the demo, we’ve made a little booklet with some placeholder text and images from NASA HQ. The images are licensed under the Creative Commons Attribution-NonCommercial 2.0 Generic License. The placeholder text is by http://hipsteripsum.me/.
Please notice that this is very experimental and just a proof-of-concept. It was tested in the latest versions of Safari, Chrome and Safari Mobile. The behavior is unfortunately not as nice as expected in Firefox.
Tiny break: 📬 Want to stay up to date with frontend and trends in web design? Subscribe and get our Collective newsletter twice a tweek.
There are probably still many undiscovered bugs and although Safari and Chrome support all the properties used, we had to apply a couple of hacks to overcome some unexpected behavior. Let us know about your experience with it and how it performs.
Some of the jQuery plugins we are using for this:
- History.js for keeping track of the current state/pages
- TouchSwipe for dragging and swiping the pages
- Modernizr for checking browser support of the CSS properties
The HTML is build up of a main wrapper with the class container and the ID flip. Inside, we’ll have all the pages, the first one being the cover and the last one being the back of the booklet. The other pages will contain some title element and boxes. These boxes will each need an additional “height” and “width” class which will give the element percentage-based dimensions. For example, w-50 is a class that will give the element a width of 50%. Depending on how a page should be laid out, we would add a fitting set of items:
<div id="flip" class="container"> <div class="f-page f-cover"> <!-- ... --> </div> <div class="f-page"> <div class="f-title"> <!-- ... --> </div> <div class="box w-50 h-100"> <div class="img-cont img-1"></div> <h3>Headline <span>Published May 7, 2012</span></h3> <p>Some text</p> </div> <div class="box w-50 h-100"> <!-- ... --> </div> </div> <div class="f-page"> <!-- ... --> </div> <!-- ... --> <div class="f-page f-cover-back"> <!-- ... --> </div> </div>
We are applying some “tricks” for making everything work responsively. The images are background-images and we set the background size of that element to “cover” while leaving the width and height fluid, in percentages. That’s of course not how it should be done. But it’s just for demonstration purpose. The teaser text is already loaded, and just “cut off” because the box is set to overflow “hidden”. To make it look smoother, we’ve just added a pseudo-element with a white to transparent gradient which covers the last bit of the box.
A great help for creating responsive layouts like these is this:
* { box-sizing: border-box }
which finally got the attention it deserves thanks to this article by Paul Irish. When laying out elements using percentages it really comes in handy to use the border-box value since we can for example, define paddings in pixels and not break our 50% width box.
We will use jQuery Templates for creating the book structure:
<script id="pageTmpl" type="text/x-jquery-tmpl"> <div class="${theClass}" style="${theStyle}"> <div class="front"> <div class="outer"> <div class="content" style="${theContentStyleFront}"> <div class="inner">{{html theContentFront}}</div> </div> </div> </div> <div class="back"> <div class="outer"> <div class="content" style="${theContentStyleBack}"> <div class="inner">{{html theContentBack}}</div> </div> </div> </div> </div> </script>
The trick is to create a left side and a right side of a page, hiding half of each side to make it appear as one.
Before we call our experimental plugin, we need to check browser support first:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> var $container = $( '#flip' ), $pages = $container.children().hide(); Modernizr.load({ test: Modernizr.csstransforms3d && Modernizr.csstransitions, yep : ['js/jquery.tmpl.min.js','js/jquery.history.js','js/core.string.js','js/jquery.touchSwipe-1.2.5.js','js/jquery.flips.js'], nope: 'css/fallback.css', callback : function( url, result, key ) { if( url === 'css/fallback.css' ) { $pages.show(); } else if( url === 'js/jquery.flips.js' ) { $( '#flip' ).flips(); } } }); </script>
If there is browser support for CSS 3D transforms and transitions we’ll load all the other necessary scripts and call our flips plugin.
Please note again that it’s only experimental, but nonetheless, I hope you find it interesting.
Good like that
Really impressive page layout. Anyway of making it work with Firefox as well? And how stable is for implementing it in a proper website?
Works fine in Firefox 12 here.
@Chris did you try clicking on any of the content, just made sure I was up to date and the content modal boxes do not work,
Now it works! 🙂 Thanks for pointing that out.
@Pedro: Nice work on this btw, don’t want to be just complaining in the comments :p
No problem. Thanks for your feedback!
Excellent! loved it. Thanks for sharing
awesome
thats awesome
The bit that doesn’t work in firefox is the modal box display… why not fix that up before writing the article instead of continuing the webkit problem mobile developers are creating?
If the future is mobile and mobile is webkit, then the future is webkit. Deal with it.
@Ian We’ve had this problem before with Netscape and Internet Explorer, IE won and look what happened. I like webkit, it’s a good engine, but we can’t have mono culture in technology, it always leads to stagnation. Deal with that.
Wow, that’s amazing! Thanks for the great work! U Rock!!
Excellent!!!!!
Excelente !!
God Like 😀
this is amazing, thanks for sharing!
let’s you… :'(
Super Duper Duper Duper Niiiiiiiiiiiiiiiiiiiiiice!
Excelent, love it!
Nice effect! Just wanted to point out that jquery templates are on their way out, to be replaced with a jQuery UI feature that is yet unannounced. In the meantime, I’ve switched over to Handlebars based on the benchmarks from this site – http://jsperf.com/dom-vs-innerhtml-based-templating/433
Tears in my eyes. This is beautiful.
Awesome.
WHy i can not do this in my site? dont work =(
The demo works exellent in Firefox for me.
Nice work!
Es bueno, pero le falta bastante trabajo.
Felicitaciones !
Daniel.
O_O
dude … wow. just wow.
Hmm I like it but it is not clear enough to see that articles are just excerpts and you have to click to full article. The page flip effect looks okay but not very natural except you like to buy news papers printed on plastic papers 😉
But I like the blur effect allot!
not works in chrome 18.0.1025.168 m… only ipad… but is great!
To me this is fantastic. It perfectly works with safari . I have seen flip-able magazine before, such as Porsche magazine, but I’m not sure what’s different between your case and those magazines in terms of backend.
Thank you
Cool project!
Works beautifully and I love how it’s mobile friendly. I would suggest you add thumbs to the mobile version too to make it more interesting and size it to fit img { max-width: 100%; }
It is nice but doesn’t work in FF – It is just a full page
Cool that it still displays as a normal web page without having to “redirect to a version for older browsers.”
After I read your ‘It’s just a full page” I fired up Firefox to see what it looks like, and was slightly disappointed that it worked perfectly. 🙂 I’m using Firefox 12. Now I gotta find something older to see how nicely it degrades.
This is fantastic 🙂 waw!!!!
super!!!!!!!!!!!!!!!!
Awesome!
Wowwwwwwww very good, very codrops …
+1 hipster lorem
firefox 10.0 is good work…
this is full stylish \m/
Incredible ! 🙂
You are a great! Great idea!
This is a terrific demo and a perfect browser application for magazines and news based sites. I love Flipboard and have also been very turned on by how Zite works. Very nice job, and thank you for sharing the code.
As cool as the flip animation is, the thing that has always been amazing to me about the Flipboard UI is the fact that they provide just enough info on the article for me to know to clickthrough or to skip. You did a nice job with this. I love the fade to open the article and return to the board layout. Great POC.
A similar effect is achieved with TurnJs which works in a wider amount of broswers, however your demo is also quite nice !
Very nice and it works in FF 13 (osx) also
Fantastic work mate. Would be really useful if you could make it compatible with other browsers too. Good job.
Not working in chrome 18.0.1025.168 m? :/ Or may be I dont know how to use it.. !
hum… I have the same version… and… it works!
Works perfectly in same version for me.
I have the same version and it does not work.
Same version. Not working for me too. Also, if it helps, I am on ubuntu 12.04 64bit.
Indeed, it does not work on Chrome version 18.0.1025.168 on Linux 🙁
Is this free to use? I would like to use on a current project. Hollar back!
It’s a great Great GREAT WORK!! it’s just wonderful!! thanks for this!!
When I first saw Flipboard I was really impressed by its design. Most likely I will use this
Great work, well done!
Hi Pedro
I really like this unique page effect, I think something like this really helps to engage the user. The script would be ideal for a magazine or newspaper website. If I had one criticism it would be that it is not instantly clear how to flip the internal pages, but I’m sure this could be easily modified.
Cathy
“EXPERIMENTAL PAGE LAYOUT INSPIRED BY FLIPBOARD” is not working for me.
I sure like to be the guinea pig for this experiment for my online book site. any suggestions to to point other users that cant see this layout?
The beginning I did not know what it thought the chrome does not work, it now appears a great effect
Thanks for the amazing work!! I’ve been experimenting with this & loving it more each passing minute.
I do have one question though…
What should I be looking at, if I want to make the flip effect vertical instead of horizontal?
i.e. if I want to drag the page from bottom to top as opposed to, dragging it from left to right.