为什么 SVG 图像的高度为 150px
问题说明
为什么这个 SVG 图像在这个 500 像素的容器内以 150 像素的高度显示?为什么是这个特定值?
Why is this SVG image displayed at 150px height inside this 500px container? Why this specific value?
我在 js bin 和 Codepen 中都发现了这种奇怪的行为,所以我认为这与我的代码有关,而不是与在线编辑器有关.
I found this weird behavior in both js bin and Codepen, so I think it is something to do with my code and not with the online editors.
注意:一个 700px 的 div 容器会产生同样的结果.所以父母的身高并不重要.
Note: a 700px div container results in the same thing. So the height of the parent doesn't matter.
<div style="padding: 30px; background-color: yellow; height: 500px; width: 500px; ">
<svg>
<pattern x="10" y="10" patternUnits="userSpaceOnUse" >
<rect x= "0" y="0"
stroke = "red"
stroke-
fill = "black"/>
</pattern>
<!-- <rect x="0" y="0" // why this deletes the bottom line? -->
<!-- <rect x="0" y="0" // why this deletes 1 px from the bottom line? -->
<!-- but this 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"
stroke= "red"
stroke-
fill="url(#basicPattern)" />
</svg>
正确答案
您没有设置 SVG width
和 height
,所以它转到默认大小300 px 宽 x 150 px 高(对于某些用户代理).
You didn't set the SVG width
and height
, so it goes to the default size of 300 px width x 150 px height (for some user-agents).
这是您的 JSBin,SVG 宽度和高度都设置为 500 像素.现在矩形可以超过 150 像素的高度:https://jsbin.com/yafenemawe/1/edit?html,输出
Here is your JSBin with the SVG width and height both set to 500px. Now the rectangle can go beyond 150px of height: https://jsbin.com/yafenemawe/1/edit?html,output
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfjjfa
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20