getBoundingClientRect,内联SVG的高度值不正确

use*_*679 6 html javascript html5 svg getboundingclientrect

<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
Run Code Online (Sandbox Code Playgroud)

我想要获得父div的宽度和高度.无论出于何种原因,getBoudingClientRect给我一个不正确的高度值(205或204.5)宽度是正确的,但高度是关闭的.有任何想法吗?

http://jsfiddle.net/jTvaF/5/

小智 3

给svg赋予display:block属性;它应该开始正确输出。