Jamie Hill
Photo of Jamie Hill

UX Designer, CSS Wizard, Ruby on Rails Developer.

jQuery Colorbox within "overflow:hidden" container in Webkit

Wow, that’s a mouthful of a title.
Just run into an interesting bug in Webkit I believe. When using Colorbox on a link contained inside a div who’s overflow attribute was set to hidden, the div was being scrolled to the bottom when hitting the “close” link of the colorbox. This only seemed to happen in Webkit browsers.
The solution was to watch for a scroll event on the div in question and scroll back to 0:

$(document).ready(function() {
  var viewer = $('#viewer');
  viewer.scroll(function() { viewer.scrollTop(0); });

Obviously, this is only a fix when you require your content to always be scrolled to the top, however this could serve as a starting point for other scenarios.