GetBoundingClientRect, invalid height value for embedded SVG
<body style="width:1000px;height:1000px;"> <div id="d" style="display:inline-block;"> <svg id="s" xmlns="http://www.w3.org/2000/svg" version="1.1" width="200px" height="200px"> <rect width="200px" height="200px" style="fill:rgb(0,0,255);"/> </svg> </div> </body> var div = document.getElementById('d'); var rect = div.getBoundingClientRect(); alert(rect.width); //200 alert(rect.height); //205 (in safari), 204.5 in other browsers var svg = document.getElementById('s'); var rect = svg.getBBox(); alert(rect.width); //200 alert(rect.height); //200 I am trying to get the width and height of a parent div. For some reason, getBoudingClientRect is giving me the wrong height value (205 or 204.5). The width is correct, but the height is disabled. Any ideas?
+6