我目前有在这个例子中正确对准联SVG边界DIV中,类似的原因。
I currently have problems aligning inline SVG correctly inside a bounding DIV, like in this example.
<!DOCTYPE html>
<html>
<body>
<div style="border: 1px solid black; height: 50px; width: 100px; vertical-align:top;">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"">
<rect x="0" y="0" width="100" height="100" style="fill: red;" />
</svg>
</div>
</body>
</html>
该SVG被调整,以匹配div的尺寸,但我不能设置任何对齐方式SVG。无论是文本对齐,也没有垂直对齐似乎在Firefox 9,镀铬18,IE 9或Opera 11.61的工作。我只是想在格的左上角放置联SVG。
The SVG gets resized to match the the dimensions of the div, but I am not able to set any alignment for the SVG. Neither text-align nor vertical-align seem to work in Firefox 9, Chrome 18, IE 9 or Opera 11.61 . I just want to position the inline SVG at the upper left corner of the DIV.
请注意,在我的情况下,周围的DIV具有动态dimmension(% - 值),因此,使用绝对定位不起作用。
Note that in my case the surrounding DIV has dynamic dimmension (%-values), so using absolute positioning does not work.
任何人有任何线索如何对齐SVG在这种情况下?
Anybody have any clue how to align the SVG in this case?
添加 preserveAspectRatio =xMinYMin
作为对SVG元素,例如一个属性 http://jsfiddle.net/longsonr/fLWhu/
Add preserveAspectRatio="xMinYMin"
as an attribute on the svg element e.g. http://jsfiddle.net/longsonr/fLWhu/