Created
August 2, 2011 19:39
-
-
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/.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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