2-blocks-template
July 2, 2015 | 11 Feedbacks

2 Blocks Template

A template split in 2 animated blocks of content, inspired by dropbox.com/guide.
Browser support
  • ie
  • Chrome
  • Firefox
  • Safari
  • Opera
9+

Today’s nugget is a simple template inspired by the awesome Dropbox Guide website. On bigger devices, the content is split in two main containers. When the user surfs through the content using the navigation, new content overlaps the old one. On smaller devices, we have a simple gallery of projects, with a slide-in panel containing additional project information.

Images: Unsplash

Creating the structure

The html structure is composed by two unordered lists, one (.cd-images-list) containing the project images (set as background-image of the .cd-images-list > li items), the other containing the project descriptions, both wrapped in two different <div> elements.
An additional ul.block-navigation has been used to create the project navigation.

Adding style

On the mobile version, the .cd-content-block element (containing the project descriptions) is in fixed position and translated outside the viewport (to the right) so that only project images are visible. When the user taps/clicks one of the projects, the .cd-content-block is translated back into the viewport (using the .is-visible class), while the .is-selected class is assigned to the list item containing the selected project information (its opacity and visibility properties are set, respectively, to 1 and visible).

On bigger devices (viewport width bigger than 768px), both the .cd-image-block (images container) and .cd-content-block (descriptions container) have  a width: 50%, an height: 100% and an overflow: hidden (this way children elements which are outside this area won’t be visible).

By default, both .cd-image-block > ul > li and .cd-content-block > ul > li are translated to the right (translateX(100%)), so that they are not visible due to their parents overflow value.

When a project is selected, the two corresponding list items (one for the project image and the other for the project info) are moved back (using the .is-selected class) so that they become visible.

Events handling

We used jQuery to implement the project navigation (both keyboard and previous/next navigation) and to detect click events on the .cd-images-list > li > a elements (mobile version) to open the slide-in panel.

The updateBlock() function has been defined to update the visible project, and it is triggered both on mobile (when the user clicks/taps a project image) and desktop version (when the user surfs through projects using the navigation/keyboard).

 

Changelog

July 2, 2015
  • Resource released by CodyHouse

Claudia Romano

Web developer, fan of The Big Bang Theory and good food. Co-founder of CodyHouse and Nucleo. You can follow her on Twitter.

  • Nitin

    Awesome, with a definite real world use case

  • Reza

    im gonna kill myself :/ this is awesome !

  • http://www.vigorlean.com Imre

    Nice work as always!!!

    When resized in Chrome and Firefox, there are two scroll bars appearing: http://screencast.com/t/fxOZwKui90S
    Not an issue just doesn’t look nice.

    On the other side, it is not very likely people will resize their browser windows that much.

    On my android phone on chrome it looks nice no double scroll-bar.

    keep up the good work!

  • Debra Chiang

    Love it! Thank you :)

  • https://www.facebook.com/rodrigochavesdesenvolvedor Rodrigo Chaves

    Very useful,and beautiful, thanks o/

  • 陳彥澄

    Awesome!Thank you.

  • Surjith SM

    The UI effects are nice. but I’m not a fan of right side content. It distracts reading. Text should be center. I wonder how dropbox keeps that layout.

    Also, guys can you remove cd- from the class name? its better to have a generic class names, so that everyone can use it :)

    • Juan Pablo Solano

      Yes. What does the cd stands for?

      • Surjith SM

        C & D in Cody maybe

  • LotharVM

    As far as I can see it’s not possible to have a direct link to one of the project pages, am I right?

  • Elena

    Didn’t show up in Safari 7.0.6…