Consider de following markup:
-
ok also not pretty but this is how I do it (disclaimer: I stole this from somewhere once)
var height = elem.clientHeight + getBufferHeight(elem, true);
function getBufferHeight(elem, includeMargins) {
if (!elem.visible()) {
return 0;
}
//do new Number instead of parseFloat to avoid rounding errors
var result = 0;
if (includeMargins) {
result =
new Number(elem.getStyle('marginTop').replace(/[^\d\.]/g, '')).ceil() +
new Number(elem.getStyle('marginBottom').replace(/[^\d\.]/g, '')).ceil();
}
result +=
new Number(elem.getStyle('borderBottomWidth').replace(/[^\d\.]/g, '')).ceil() +
new Number(elem.getStyle('borderTopWidth').replace(/[^\d\.]/g, '')).ceil() +
new Number(elem.getStyle('paddingTop').replace(/[^\d\.]/g, '')).ceil() +
new Number(elem.getStyle('paddingBottom').replace(/[^\d\.]/g, '')).ceil();
return result;
}