You may need to conduct a performance test yourself to find out which method is the fastest, but in any case it is a pretty quick way. ( jsfiddle )
function getOuterBoxDimensions() { var original = document.getElementById('original'), divs = original.getElementsByTagName('div'), left = 0, right = original.offsetWidth, top = 0, bottom = original.offsetHeight; for (var i = 0, div; div = divs[i++];) { if (div.offsetTop < top) { top = div.offsetTop; } if (div.offsetTop + div.offsetHeight > bottom) { bottom = div.offsetTop + div.offsetHeight; } if (div.offsetLeft < left) { left = div.offsetLeft; } if (div.offsetLeft + div.offsetWidth > right) { right = div.offsetLeft + div.offsetWidth; } } return { top: top, left: left, bottom: bottom, right: right };
As far as I know, offsetLeft, offsetWidth, etc. will return the correct sizes whether box-sizing: border-box or not. If you have a div inside the inner divs, then everything will be a little more complicated - you will need to check only those divs that are the childNodes of the original.
EDIT: Here is an extended version that takes fields into account properly and expands a new container to accommodate all floating divs on one line (see discussion in the comments). http://jsfiddle.net/m7N2J/10/
function getOuterBoxDimensions() { var original = document.getElementById('original'), divs = original.getElementsByTagName('div'), left = 0, right = original.offsetWidth, top = 0, bottom = original.offsetHeight, d = document.defaultView, style, marginTop, marginBottom, marginLeft, marginRight, float, floatWidth = 0; for (var i = 0, div; div = divs[i++];) { if (style = div.currentStyle) { // May be possible to exclude this if IE7/8 not needed marginTop = parseFloat(style.marginTop); marginBottom = parseFloat(style.marginBottom); marginLeft = parseFloat(style.marginLeft); marginRight = parseFloat(style.marginRight); float = style.float; } else { style = d.getComputedStyle(div, null); marginTop = parseFloat(style.getPropertyValue('margin-top')); marginBottom = parseFloat(style.getPropertyValue('margin-bottom')); marginLeft = parseFloat(style.getPropertyValue('margin-left')); marginRight = parseFloat(style.getPropertyValue('margin-right')); float = style.getPropertyValue('float'); } if (float == 'left' || float == 'right') { floatWidth += div.offsetWidth + marginLeft + marginRight; if (div.offsetHeight + marginBottom > bottom) { bottom = div.offsetHeight + marginBottom; } } else { if (div.offsetTop - marginTop < top) { top = div.offsetTop - marginTop; } if (div.offsetTop + div.offsetHeight + marginBottom > bottom) { bottom = div.offsetTop + div.offsetHeight + marginBottom; } if (div.offsetLeft < left - marginLeft) { left = div.offsetLeft - marginLeft; } if (div.offsetLeft + div.offsetWidth + marginRight > right) { right = div.offsetLeft + div.offsetWidth + marginRight; } } } if (right < left + floatWidth) { right = left + floatWidth; } return { top: top, left: left, bottom: bottom, right: right }; // Note that dimensions are relative to the original div }