Skip to content

Instantly share code, notes, and snippets.

@cburgmer
Created August 2, 2011 19:39
Show Gist options
  • Save cburgmer/1121011 to your computer and use it in GitHub Desktop.
Save cburgmer/1121011 to your computer and use it in GitHub Desktop.
Here is a quick snippet how to test if overflow is happening in a DOM element, shamelessly taken from http://www.bramstein.com/projects/text-overflow/.
// Check if overflow happens for a given jquery element
function check_overflow(element) {
var element_clone = element.clone();
element.after(element_clone.hide().css({
'position': 'absolute',
'width': 'auto',
'overflow': 'visible',
'max-width': 'inherit'
}));
var has_overflow = element_clone.width() > element.width();
element_clone.remove();
return has_overflow;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment