为什么这个SVG图像在这个500px容器内显示为150px高?为什么是这个特定的值?
我在js bin和Codepen中发现了这种奇怪的行为,所以我认为这与我的代码有关,而不是在线编辑器有关。
注意:一个700像素的div容器会产生相同的效果。因此父元素的高度并不重要。<div style="padding: 30px; background-color: yellow; height: 500px; width: 500px; ">
<svg>
<pattern id="basicPattern" x="10" y="10" width="40" height="40" patternUnits="userSpaceOnUse" >
<rect x= "0" y="0" width="4" height="4"
stroke = "red"
stroke-width = "1"
fill = "black"/>
</pattern>
<!-- <rect x="0" y="0" width="300" height="151" // why this deletes the bottom line? -->
<!-- <rect x="0" y="0" width="300" height="150" // why this deletes 1 px from the bottom line? -->
<!-- but this height="149" is the bottom limmit for this picture..
what prevent's it bor beeing extended further - we have unthil 500 px as you can see on the div.-->
<rect x="0" y="0" width="300" height="149"
stroke= "red"
stroke-width="2"
fill="url(#basicPattern)" />
</svg>
<video>
元素定义了这些尺寸,但没有为SVG定义。您知道任何支持此说法的来源吗? - altocumulus