Monday, January 23, 2017

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…
source : https://codyhouse.co/gem/cross-reference-table/
download : https://codyhouse.co/redirect/?resource=cross-reference-table

Back To Top

his "Back to top" link allows users to smoothly scroll back to the top of the page. It's a little detail which enhances navigation experience on website with long pages.
Browser support
  • ie
  •  
  • Chrome
  •  
  • Firefox
  •  
  • Safari
  •  
  • Opera
9+
This resource is suitable for website with lots of page content. The link fades in on the right-hand side of the content area, after the browser window has been scrolled beyond a certain point, and remains fixed during scrolling.
If users keeps on scrolling, the button nicely reduces its opacity to be less distracting during navigation.

Creating the structure

We inserted the “Back to top” link at the bottom of our content, before the closing tag.

Adding style

The link will appear fixed on the right-side of the content. Initially it has a visibility:hidden; and an opacity:0;.
Both visibility and opacity are controlled through two classes: .cd-is-visible and .cd-fade-out.
These classes are added (or removed) to the “Back to top” link using jQuery.

Events handling

In our .js file, we have defined three variables to control the “Back to top” link appearance:
The offset variable will be used to toggle the class .cd-is-visible; the offset_opacity, instead, to add the .cd-fade-out class.
The top scrolling function is implemented using the jQuery .animate() method, and bound to the “Back to top” click event.

source : https://codyhouse.co/gem/back-to-top/
download source : https://codyhouse.co/redirect/?resource=back-to-top