cross reference table preview
May 26, 2014 | 38 Feedbacks

Cross reference table

Tables are indispensable parts of web designs. They let you visually organise tabular content, distributing it on rows and columns. Although they are quite easy to design and code for large screens, things get more complicated on smaller devices.
Browser support
  • ie
  • Chrome
  • Firefox
  • Safari
  • Opera
9+

Whether it’s a subscription plan or a checkout process, you must deal with tables in your projects. And you must deal with responsiveness too. I’ve noticed some websites just cut off some columns to make their tables fits on a phone, but this solution doesn’t work in most cases (at least not if you need 5+ columns). I found this good example of a responsive table which inspired this resource: the list of features gets fixed on a side, allowing the user to horizontally scroll through the columns. Nice!

Now why didn’t I use the HTML table structure, and instead went with unordered lists? It was difficult for me to make this resource responsive using proper table semantics (maybe an idea for a future resource). So I thought more about the UX side, and less about the code behind it. Yep, that’s my excuse.

Creating the structure

We used a <section> as container of the table. The header contains the features (what properties are we comparing?). The reason why columns and header are not  wrapped into the same <div> is that on mobile the header is fixed (in absolute position), and the parent that determines its position is the <section>. On the other side the columns will keep scrolling on smaller devices.

As anticipated, columns data are just list items.

Adding style

Nothing fancy into the CSS. Just one thing to point out: we wrapped the columns into 2 <div>, .cd-table-container and .cd-table-wrapper. Why two and not just one? Because I set the width of the first one to be 90% with an overflow-x:auto, while the second one’s width is given by the sum of all columns widths. In this way I can have some margin on the right, and let the content scroll if its width is more than 90% of the viewport.

table responsive image preview

Events handling

We used jQuery only to remove the small right arrow that appears on small screens (to indicate that it’s possible to scroll right), and the subtle gradient on the right side – that we added always to indicate that there’s more content – at the end of the scrolling.

That’s it! Any idea/suggestion/criticism is welcome in the comments. Criticism, even the constructive one, could be deleted. Just saying…

Changelog

June 01, 2014
  • Added table scroll movement when user clicks on the arrow - by CodyHouse
May 26, 2014
  • Resource released by CodyHouse

Sebastiano Guerriero

UI/UX designer, with a huge passion for Nutella. Co-Founder of CodyHouse. You can follow him on Twitter or Dribbble.

  • Ekaterina Alexandrovna

    That’s an awesome feature! Only I would replace the bouncing arrow with something more intuitively hinting to make a scroll movement instead of unfruitfully clicking on the arrow. Something like a sliding ball animation in combination with this scroll would make a great new pattern!

    • Sebastiano Guerriero

      Interesting point. Agreed, the arrow looks like something you should click on, need to think about something different.

      • daniel fosco

        Was about to comment on this, tried to click the arrow as well.

        Great gem nonetheless! :)

        • Sebastiano Guerriero

          Hi Daniel,

          Yep, definitely something we need to change. For now we’ll make the arrow clickable, until we find a better solution. Will upload a new version ASAP (we will update the changelog as soon as the new version is available)

  • Sebas

    Stop lying, that is not a table!

  • Andy

    Umm, there’s no arrow on the demo.. Am I missing something?

    • Sebastiano Guerriero

      Hey Andy, the arrow pops in only when the table size is bigger than the viewport size (resize the browser or check the demo from a touch device)

      • Andy

        Aha! Thanks a lot… great site, great idea. Really looking forward to seeing it grow.

  • Pingback: [js/css] 実用性の高い色々なライブラリが揃う「Cody」 | VIVABlog()

  • Thiago Lagden Magalhães

    Powerfull… I thought: Your solution is prettier than mine.

  • Pingback: استایل جدول تعرفه ها اسکرول خور()

  • Pingback: Blue Coaster33()

  • wollmilchsau

    Hi, thank you for the great work. What should I do if I need 7 columns instead of the 5 columns. The 7 column always travels with me in a new line :) Thanks for your help!

    • http://codyhouse.co Claudia Romano

      Hi,
      if you’re using sass, you need to change the $cd-column-number variable in partials/_variables.scss. Otherwise, in the style.css, you need to change the .cd-table-column width and the .cd-table-wrapper padding. Hope this helps!

  • Pingback: parking()

  • Pingback: water ionizer loan()

  • Pingback: parking()

  • Pingback: reference()

  • Pingback: locksmith teambackpack()

  • Pingback: plumbing camera endoscope()

  • Pingback: house blue()

  • Pingback: electrician canada salary()

  • Pingback: electrician school new jersey()

  • Pingback: HD Coloring Pages()

  • Pingback: water ionizer()

  • Pingback: pay day loans()

  • Pingback: pay per day loans plan()

  • Pingback: water ionizer loans()

  • Pingback: ppl electric()

  • Pingback: water ionizer()

  • Pingback: alkaline water()

  • Pingback: view website()

  • Pingback: http://webkingz.camkingz.com/()

  • Pingback: alkaline water()

  • Pingback: click this()

  • Pingback: here()

  • Gerben Dol

    This is really helpfull. I’m having a pain finding something like this, but also with a fixed header. I’m building a timetable and need to cross reference events at certain dates/location.

  • Wira Andhika

    hi, i’m having responsiveness issue on mozilla firefox 46.01
    anyone have the same issue, and sollution?