Smooth scroll to internal hash links, revisited

An improved code snippet I’m mostly putting here for my own reference:

$('a[href*=#]').on('click',function(e) { 
  var id = $(this).attr('href').match(/#\w+$/)[0];
  if ($(id).length) { // otherwise, it's a link to a different page
    e.preventDefault();
    var top = $(id).offset().top;
    $('html,body').animate({'scrollTop':top}, 'fast', function() {
      if ("onhashchange" in window) { // test if hashchange is available
        history.pushState(null,null,id);
      } else {
        window.location.hash = id;
      }
    });
  };
});

Two-column lists when order doesn’t matter

I’m working on a site that uses an extended navigation menu grouped into sub-sections. Each section, in turn, groups its links into two columns of roughly equal height.

In CSS and HTML, this can be a pain. You can break the columns yourself, of course, but you have to maintain that every time there’s a change.

Or, if the order of the links doesn’t particularly matter, you can just float alternating elements to the left and right. Kind of like this: Continue reading Two-column lists when order doesn’t matter