6
<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
के लिए गलत ऊंचाई मान माता-पिता div की चौड़ाई और ऊंचाई प्राप्त करने का प्रयास कर रहा हूं। किसी भी कारण से, GetBoudingClientRect मुझे गलत ऊंचाई मान दे रहा है (205 या 204.5) चौड़ाई सही है, लेकिन ऊंचाई बंद है। कोई विचार?getBoundingClientRect, इनलाइन एसवीजी
ऊंचाई सही है, यह 204.5 पिक्सेल ऊंची है। – Stijn
यह 200px – user2800679
संभव डुप्लिकेट होना चाहिए [HTML5 में कैनवास/वीडियो/ऑडियो तत्वों के नीचे एक 4 पीएक्स अंतर है] (http://stackoverflow.com/questions/8600393/there-is-a-4px-gap-below- कैनवास-वीडियो-ऑडियो-तत्व-इन-एचटीएमएल 5) – Stijn